From 45954d837d62d71bb3924a569b6638d20774fa64 Mon Sep 17 00:00:00 2001 From: jakcron Date: Sun, 15 Apr 2018 14:00:46 +0800 Subject: [PATCH] Add makeDirectory() to fnd::io --- lib/libfnd/include/fnd/io.h | 1 + lib/libfnd/source/io.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/libfnd/include/fnd/io.h b/lib/libfnd/include/fnd/io.h index d5ace2a..78c1cc0 100644 --- a/lib/libfnd/include/fnd/io.h +++ b/lib/libfnd/include/fnd/io.h @@ -11,5 +11,6 @@ namespace fnd 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 byte_t* data, size_t len); + void makeDirectory(const std::string& path); } } diff --git a/lib/libfnd/source/io.cpp b/lib/libfnd/source/io.cpp index 816190f..34f9dce 100644 --- a/lib/libfnd/source/io.cpp +++ b/lib/libfnd/source/io.cpp @@ -1,5 +1,10 @@ #include #include +#ifdef _WIN32 +#include +#else +#include +#endif using namespace fnd; @@ -125,3 +130,12 @@ void io::writeFile(const std::string & path, const byte_t * data, size_t len) 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 +} \ No newline at end of file