Skip to content

Commit

Permalink
Fixed some issues with createDirectories()
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Dec 8, 2023
1 parent 8671792 commit 8fb8079
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
24 changes: 24 additions & 0 deletions source/FAST/Tests/UtilityTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ TEST_CASE("Split", "[split][utility]") {
CHECK(parts[0] == "\"Wee sad");
CHECK(parts[1] == "asd asd ");
CHECK(parts[2] == "asdasd\"");

parts = split("test", "/");
REQUIRE(parts.size() == 1);
CHECK(parts[0] == "test");
}

TEST_CASE("Replace", "[replace][utility]") {
Expand Down Expand Up @@ -65,4 +69,24 @@ TEST_CASE("getFileName", "[getFileName][utility][fast]") {
CHECK(getFileName(str) == "asd_asd.txt");
str = "asd asd.txt";
CHECK(getFileName(str) == "asd asd.txt");
}

TEST_CASE("createDirectories", "[createDirectories][utility][fast]") {
std::string name = "create_directories_test";
CHECK_NOTHROW(createDirectories(name));
CHECK(isDir(name));

std::string name2 = "create_directories_test2/test2/";
CHECK_NOTHROW(createDirectories(name2));
CHECK(isDir(name2));

std::string name3 = "create_directories_test3/test3/test3/";
CHECK_NOTHROW(createDirectories(name3));
CHECK(isDir(name3));

#ifdef WIN32
std::string name4 = "create_directories_test4\\test4\\";
CHECK_NOTHROW(createDirectories(name4));
CHECK(isDir(name4));
#endif
}
10 changes: 3 additions & 7 deletions source/FAST/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,10 @@ void createDirectories(std::string path) {
}

directories = filteredDirectories;
#ifdef _WIN32
std::string currentPath = directories[0];
#else
std::string currentPath = "/" + directories[0];
#endif
std::string currentPath = "";
// Create each directory needed
for(int i = 1; i < directories.size(); ++i) {
currentPath += "/" + directories[i];
for(int i = 0; i < directories.size(); ++i) {
currentPath += directories[i] + "/";
try {
createDirectory(currentPath);
} catch(ExistException &e) {
Expand Down

0 comments on commit 8fb8079

Please sign in to comment.