mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Adds explicit check for VFS create alignment
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "lib/self_test.h"
|
||||
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/file/file_system.h"
|
||||
#include "lib/file/vfs/vfs.h"
|
||||
#include "lib/os_path.h"
|
||||
@@ -80,7 +81,8 @@ public:
|
||||
createRealDir(TEST_FOLDER / "cache" / "some_folder");
|
||||
createRealDir(TEST_FOLDER / "some_mod" / "cache" / "some_mod");
|
||||
|
||||
std::shared_ptr<u8> buf(new u8(1));
|
||||
std::shared_ptr<u8> buf;
|
||||
TS_ASSERT_OK(AllocateAligned(buf, 1, maxSectorSize));
|
||||
|
||||
g_VFS->Mount(L"", TEST_FOLDER / "some_mod" / "", 0, 0);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "lib/self_test.h"
|
||||
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/file/file_system.h"
|
||||
#include "lib/file/vfs/vfs.h"
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
@@ -76,7 +77,9 @@ public:
|
||||
|
||||
void test_getPathnames()
|
||||
{
|
||||
std::shared_ptr<u8> nodata(new u8);
|
||||
std::shared_ptr<u8> nodata;
|
||||
TS_ASSERT_OK(AllocateAligned(nodata, 1, maxSectorSize));
|
||||
|
||||
g_VFS->CreateFile("test_file.txt", {nodata.get(), 0});
|
||||
g_VFS->CreateFile("test_file2.txt", {nodata.get(), 0});
|
||||
g_VFS->CreateFile("test_file3.txt", {nodata.get(), 0});
|
||||
|
||||
@@ -145,6 +145,8 @@ public:
|
||||
|
||||
WARN_RETURN_STATUS_IF_ERR(st);
|
||||
|
||||
ENSURE(IsAligned(fileContents.data(), maxSectorSize));
|
||||
|
||||
const PRealDirectory& realDirectory = directory->AssociatedDirectory();
|
||||
const OsPath name = pathname.Filename();
|
||||
RETURN_STATUS_IF_ERR(realDirectory->Store(name, fileContents));
|
||||
|
||||
@@ -145,8 +145,7 @@ struct IVFS
|
||||
/**
|
||||
* Create a file with the given contents.
|
||||
* @param pathname
|
||||
* @param fileContents
|
||||
* @param size [bytes] of the contents, will match that of the file.
|
||||
* @param fileContents the pointer must be aligned to maxSectorSize
|
||||
* @return Status.
|
||||
**/
|
||||
virtual Status CreateFile(const VfsPath& pathname, std::span<const u8> fileContents) = 0;
|
||||
|
||||
Reference in New Issue
Block a user