Browse Source

Improved File class

- made "_mkdir" more generic by passing path parameter
pcmattulat 4 years ago
parent
commit
5c80d30669
2 changed files with 5 additions and 5 deletions
  1. 4 4
      source/io/File.cpp
  2. 1 1
      source/io/File.hpp

+ 4 - 4
source/io/File.cpp

@@ -106,7 +106,7 @@ bool ls_std::File::isFile()
 
 
 void ls_std::File::makeDirectory()
 void ls_std::File::makeDirectory()
 {
 {
-  if(this->_mkdir()) {
+  if(ls_std::File::_mkdir(this->absoluteFilePath)) {
     throw ls_std::FileOperationException {this->absoluteFilePath};
     throw ls_std::FileOperationException {this->absoluteFilePath};
   }
   }
 }
 }
@@ -156,15 +156,15 @@ bool ls_std::File::_isFile()
   return match;
   return match;
 }
 }
 
 
-int ls_std::File::_mkdir() {
+int ls_std::File::_mkdir(const std::string& path) {
   int result {};
   int result {};
 
 
   #ifdef _WIN32
   #ifdef _WIN32
-    result = mkdir(this->absoluteFilePath.c_str());
+    result = mkdir(path.c_str());
   #endif
   #endif
 
 
   #ifdef unix
   #ifdef unix
-    result = mkdir(this->absoluteFilePath.c_str(), 0777);
+    result = mkdir(path.c_str(), 0777);
   #endif
   #endif
 
 
   return result;
   return result;

+ 1 - 1
source/io/File.hpp

@@ -45,7 +45,7 @@ namespace ls_std {
       bool _exists();
       bool _exists();
       bool _isDirectory();
       bool _isDirectory();
       bool _isFile();
       bool _isFile();
-      int _mkdir();
+      static int _mkdir(const std::string& path);
       static std::string _normalizePath(std::string path);
       static std::string _normalizePath(std::string path);
   };
   };
 }
 }