Support NULL in dir parameter in mj_addFileVFS.
Fixes #2839. PiperOrigin-RevId: 807208005 Change-Id: I8def3b1e388dc19fa2fa8a92d53abef30dee5b88
This commit is contained in:
committed by
Copybara-Service
parent
dd398f47b9
commit
ac4874226c
@@ -219,7 +219,8 @@ int mj_addFileVFS(mjVFS* vfs, const char* directory, const char* filename) {
|
|||||||
VFS* cvfs = GetVFSImpl(vfs);
|
VFS* cvfs = GetVFSImpl(vfs);
|
||||||
|
|
||||||
// make full name
|
// make full name
|
||||||
FilePath fullname = FilePath(directory, filename);
|
const char* dir = directory != nullptr ? directory : "";
|
||||||
|
FilePath fullname = FilePath(dir, filename);
|
||||||
|
|
||||||
// strip path
|
// strip path
|
||||||
FilePath newname = StripPath(filename);
|
FilePath newname = StripPath(filename);
|
||||||
|
|||||||
@@ -106,6 +106,18 @@ TEST_F(UserVfsTest, AddFileStripPath) {
|
|||||||
mj_deleteVFS(&vfs);
|
mj_deleteVFS(&vfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(UserVfsTest, NullDirectory) {
|
||||||
|
mjVFS vfs;
|
||||||
|
mj_defaultVFS(&vfs);
|
||||||
|
|
||||||
|
const std::string file = "engine/testdata/actuation/activation.xml";
|
||||||
|
const std::string path = GetTestDataFilePath(file);
|
||||||
|
mj_addFileVFS(&vfs, nullptr, path.c_str());
|
||||||
|
|
||||||
|
EXPECT_TRUE(HasFile(&vfs, "activation.xml"));
|
||||||
|
mj_deleteVFS(&vfs);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(UserVfsTest, AddFileRepeat) {
|
TEST_F(UserVfsTest, AddFileRepeat) {
|
||||||
mjVFS vfs;
|
mjVFS vfs;
|
||||||
mj_defaultVFS(&vfs);
|
mj_defaultVFS(&vfs);
|
||||||
|
|||||||
Reference in New Issue
Block a user