Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 831 vs 832 for /trunk/Source Code/Platform/PlatformDefines.cpp

Diff revisions: vs.
  @@ -58,26 +58,22 @@
58 58 return !Config::Assert::CONTINUE_ON_ASSERT;
59 59 }
60 60
61 - bool createFileIfNotExist(const char* file) {
62 - bool fileCreated = false;
63 - #if 1
64 - if (fopen(file, "rb+") == NULL)
65 - {
66 - fclose(fopen(file, "wb"));
67 - fileCreated = true;
61 + bool createDirectories(const char* path) {
62 + //Always end in a '/'
63 + assert(path != nullptr && strlen(path) > 0 && path[strlen(path) -1] == '/');
64 +
65 + vectorImpl<stringImpl> directories = Util::Split(path, '/');
66 + if (directories.empty()) {
67 + directories = Util::Split(path, '\\');
68 68 }
69 - #else
70 - std::fstream fileHandler;
71 - fileHandler.open(file, std::fstream::in | std::fstream::out | std::fstream::app);
72 69
73 - if (!fileHandler) {
74 - fileHandler.open(file, std::fstream::in | std::fstream::out | std::fstream::trunc);
75 - fileHandler.close();
76 - fileCreated = true;
70 + for (const stringImpl& dir : directories) {
71 + if (!createDirectory(dir.c_str())) {
72 + return false;
73 + }
77 74 }
78 - #endif
79 75
80 - return fileCreated;
76 + return true;
81 77 }
82 78
83 79 }; // namespace Divide