Add makeDirectory() to fnd::io

This commit is contained in:
jakcron 2018-04-15 14:00:46 +08:00
parent 886d51f63c
commit 45954d837d
2 changed files with 15 additions and 0 deletions

View file

@ -11,5 +11,6 @@ namespace fnd
void readFile(const std::string& path, size_t offset, size_t len, MemoryBlob& blob); void readFile(const std::string& path, size_t offset, size_t len, MemoryBlob& blob);
void writeFile(const std::string& path, const MemoryBlob& blob); void writeFile(const std::string& path, const MemoryBlob& blob);
void writeFile(const std::string& path, const byte_t* data, size_t len); void writeFile(const std::string& path, const byte_t* data, size_t len);
void makeDirectory(const std::string& path);
} }
} }

View file

@ -1,5 +1,10 @@
#include <fnd/io.h> #include <fnd/io.h>
#include <fstream> #include <fstream>
#ifdef _WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#endif
using namespace fnd; using namespace fnd;
@ -125,3 +130,12 @@ void io::writeFile(const std::string & path, const byte_t * data, size_t len)
fclose(fp); fclose(fp);
} }
void io::makeDirectory(const std::string& path)
{
#ifdef _WIN32
_mkdir(path.c_str());
#else
mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
}