diff options
author | Ladislav Zezula <zezula@volny.cz> | 2021-03-31 17:22:23 +0200 |
---|---|---|
committer | Ladislav Zezula <zezula@volny.cz> | 2021-03-31 17:22:23 +0200 |
commit | 804b26bb85ddfe1363a315ab938065c9549587ae (patch) | |
tree | 022a177ad836932d00bb831b59783000db9b327d | |
parent | ce159e90bca94be3c9050fe467d497cfcbe759a8 (diff) |
Test
-rw-r--r-- | src/FileStream.cpp | 22 | ||||
-rw-r--r-- | src/StormPort.h | 6 | ||||
-rw-r--r-- | test/StormTest.cpp | 14 |
3 files changed, 24 insertions, 18 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp index 50f6ea5..bfb5817 100644 --- a/src/FileStream.cpp +++ b/src/FileStream.cpp @@ -561,13 +561,11 @@ static bool BaseMap_Open(TFileStream * pStream, LPCTSTR szFileName, DWORD dwStre if(hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
- // If the file is not there and is not available for random access,
- // report error
- if(bResult == false)
- return false;
-#endif
+ // Return the result of the operation
+ return bResult;
+
+#elif defined(STORMLIB_HAS_MMAP)
-#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX)
struct stat64 fileinfo;
intptr_t handle;
bool bResult = false;
@@ -596,13 +594,15 @@ static bool BaseMap_Open(TFileStream * pStream, LPCTSTR szFileName, DWORD dwStre // Did the mapping fail?
if(bResult == false)
- {
nLastError = errno;
- return false;
- }
-#endif
+ return bResult;
- return true;
+#else
+
+ // File mapping is not supported
+ return false;
+
+#endif
}
static bool BaseMap_Read(
diff --git a/src/StormPort.h b/src/StormPort.h index 30d9e12..bd7947f 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -65,7 +65,7 @@ #define STORMLIB_CDECL __cdecl #define STORMLIB_WINDOWS - #define STORMLIB_PLATFORM_DEFINED // The platform is known now + #define STORMLIB_PLATFORM_DEFINED // The platform is known now #endif @@ -102,7 +102,8 @@ #endif #define STORMLIB_MAC - #define STORMLIB_PLATFORM_DEFINED // The platform is known now + #define STORMLIB_HAS_MMAP // Indicate that we have mmap support + #define STORMLIB_PLATFORM_DEFINED // The platform is known now #endif @@ -272,6 +273,7 @@ #endif #define STORMLIB_LINUX + #define STORMLIB_HAS_MMAP // Indicate that we have mmap support #define STORMLIB_PLATFORM_DEFINED #endif diff --git a/test/StormTest.cpp b/test/StormTest.cpp index 0993826..9a7724d 100644 --- a/test/StormTest.cpp +++ b/test/StormTest.cpp @@ -679,10 +679,10 @@ static HANDLE InitDirectorySearch(LPCTSTR szDirectory) HANDLE hFind;
TCHAR szSearchMask[MAX_PATH];
- // Keep compilers happy
+ // Construct the directory mask
_stprintf(szSearchMask, _T("%s\\*"), szDirectory);
- // Construct the directory mask
+ // Perform the search
hFind = FindFirstFile(szSearchMask, &wf);
return (hFind != INVALID_HANDLE_VALUE) ? hFind : NULL;
@@ -2169,9 +2169,12 @@ static DWORD TestOnLocalListFile(LPCTSTR szPlainName) if(SFileOpenFileEx(NULL, szFileName1, SFILE_OPEN_LOCAL_FILE, &hFile))
{
// Retrieve the file name. It must match the name under which the file was open
- SFileGetFileName(hFile, szFileName2);
- if(strcmp(szFileName2, szFileName1))
- Logger.PrintMessage("The retrieved name does not match the open name");
+ if(FileStream_Prefix(szPlainName, NULL) == 0)
+ {
+ SFileGetFileName(hFile, szFileName2);
+ if(strcmp(szFileName2, szFileName1))
+ Logger.PrintMessage("The retrieved name does not match the open name");
+ }
// Retrieve the file size
dwFileSizeLo = SFileGetFileSize(hFile, &dwFileSizeHi);
@@ -4286,6 +4289,7 @@ int _tmain(int argc, TCHAR * argv[]) if(dwErrCode == ERROR_SUCCESS)
{
+ TestOnLocalListFile(_T("FLAT-MAP:ListFile_Blizzard.txt"));
dwErrCode = TestOnLocalListFile(_T("ListFile_Blizzard.txt"));
}
|