diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-04-28 20:06:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-04-28 23:02:16 +0300 |
commit | 15919532c723ca0186b0c0c932cd1b90c7d2e570 (patch) | |
tree | 249673c7f5f06b2741826e12d7f69a9de379a52d /src/fs/virtfs | |
parent | 515323530ba1b93c8d5ba00b015bf55aa0ecb01c (diff) | |
download | plus-15919532c723ca0186b0c0c932cd1b90c7d2e570.tar.gz plus-15919532c723ca0186b0c0c932cd1b90c7d2e570.tar.bz2 plus-15919532c723ca0186b0c0c932cd1b90c7d2e570.tar.xz plus-15919532c723ca0186b0c0c932cd1b90c7d2e570.zip |
Fix code style.
Diffstat (limited to 'src/fs/virtfs')
-rw-r--r-- | src/fs/virtfs/virtfs1_unittest.cc | 6 | ||||
-rw-r--r-- | src/fs/virtfs/virtfsdir.cpp | 6 | ||||
-rw-r--r-- | src/fs/virtfs/virtfsfuncs.h | 2 | ||||
-rw-r--r-- | src/fs/virtfs/virtfszip.cpp | 8 |
4 files changed, 13 insertions, 9 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index 1ddada282..a3b1b56cc 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -2105,9 +2105,9 @@ TEST_CASE("VirtFs1 getFilesWithDir2") VirtFs::getFilesWithDir(pathJoin("evol", "icons"), list); REQUIRE(list.size() == 3); - REQUIRE(inList(list, pathJoin("evol" , "icons"), "evol-client.ico")); - REQUIRE(inList(list, pathJoin("evol" , "icons"), "evol-client.png")); - REQUIRE(inList(list, pathJoin("evol" , "icons"), "evol-client.xpm")); + REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.ico")); + REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.png")); + REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.xpm")); VirtFs::unmountDir(prefix + "data"); } diff --git a/src/fs/virtfs/virtfsdir.cpp b/src/fs/virtfs/virtfsdir.cpp index 223b45e1d..902e686c0 100644 --- a/src/fs/virtfs/virtfsdir.cpp +++ b/src/fs/virtfs/virtfsdir.cpp @@ -485,13 +485,15 @@ namespace VirtFsDir if (fstat(fd, &statbuf) == -1) { reportAlways("VirtFsDir::fileLength error."); - return -1; + if (fd != FILEHDEFAULT) + FILECLOSE(fd); + return nullptr; } fileSize = static_cast<int>(statbuf.st_size); #endif // USE_FILE_FOPEN // Allocate memory and load the file - char *restrict const buffer = new char[fileSize]; + char *restrict const buffer = new char[CAST_SIZE(fileSize)]; if (fileSize > 0) buffer[fileSize - 1] = 0; diff --git a/src/fs/virtfs/virtfsfuncs.h b/src/fs/virtfs/virtfsfuncs.h index 9f164c865..eb617ebd4 100644 --- a/src/fs/virtfs/virtfsfuncs.h +++ b/src/fs/virtfs/virtfsfuncs.h @@ -44,6 +44,8 @@ struct VirtFsFuncs final getRealDir(nullptr), enumerate(nullptr), getFiles(nullptr), + getFilesWithDir(nullptr), + getDirs(nullptr), isDirectory(nullptr), openRead(nullptr), openWrite(nullptr), diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp index 76ee69093..7d2f0e8b6 100644 --- a/src/fs/virtfs/virtfszip.cpp +++ b/src/fs/virtfs/virtfszip.cpp @@ -565,15 +565,15 @@ namespace VirtFsZip reportAlways("VirtFsZip::read buffer is null"); return 0; } - const uint32_t pos = CAST_S32(file->mPos); - const uint32_t sz = CAST_S32(file->mSize); + const size_t pos = file->mPos; + const size_t sz = file->mSize; // if outside of buffer, return if (pos >= sz) return 0; // pointer to start for buffer ready to read const uint8_t *restrict const memPtr = file->mBuf + pos; // left buffer size from pos to end - const uint32_t memSize = sz - pos; + const uint32_t memSize = CAST_U32(sz - pos); // number of objects possible to read uint32_t memCount = memSize / objSize; if (memCount == 0) @@ -582,7 +582,7 @@ namespace VirtFsZip if (memCount > objCount) memCount = objCount; // number of bytes to read from buffer - const uint32_t memEnd = memCount * objSize; + const size_t memEnd = memCount * objSize; memcpy(buffer, memPtr, memEnd); file->mPos += memEnd; return memCount; |