Add support for removing directory entries

This commit is contained in:
2017-04-26 04:01:19 -05:00
parent a7a9256503
commit 544eb94f34
4 changed files with 106 additions and 8 deletions
+1
View File
@@ -39,3 +39,4 @@ add_test("Test\\ PathIterator::fileName" FSTests PathIterator::fileName)
add_test("Test\\ FileSystem32::findInodeOf\\ /" FSTests "FileSystem32::findInodeOf /")
add_test("Test\\ FileSystem32::write\\(string\\)" FSTests "FileSystem32::write(string)")
add_test("Test\\ FileSystem32::rmDirectoryEntry\\(string\\)" FSTests "FileSystem32::rmDirectoryEntry(string)")
+32
View File
@@ -155,6 +155,38 @@ map<string, int(*)(string)> tests = {
delete []buff;
delete []dataOut;
return retval;
}
},
{
"FileSystem32::rmDirectoryEntry(string)",
[](string) {
int retval = 0;
auto path = "/usr/share/test.txt";
auto dataIn = "test string";
auto dataOutLen = ox_strlen(dataIn) + 1;
auto dataOut = new char[dataOutLen];
const auto size = 1024 * 1024 * 10;
auto buff = new uint8_t[size];
FileSystem32::format(buff, (FileStore32::FsSize_t) size, true);
auto fs = (FileSystem32*) createFileSystem(buff, size);
retval |= fs->mkdir("/usr");
retval |= fs->mkdir("/usr/share");
retval |= fs->write(path, (void*) dataIn, ox_strlen(dataIn) + 1);
retval |= fs->read(path, dataOut, dataOutLen);
retval |= ox_strcmp(dataIn, dataOut) != 0;
retval |= fs->rmDirectoryEntry(path);
// the lookup should fail
retval |= fs->read(path, dataOut, dataOutLen) == 0;
delete fs;
delete []buff;
delete []dataOut;
return retval;
}
},