DEVTOOLS: Factor out function to create directories in create_project.
This commit is contained in:
parent
19a20ad71f
commit
c00ab00f25
3 changed files with 35 additions and 30 deletions
|
@ -59,6 +59,7 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
@ -1121,6 +1122,32 @@ FileList listDirectory(const std::string &dir) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void createDirectory(const std::string &dir) {
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
if (!CreateDirectory(dir.c_str(), NULL)) {
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
error("Could not create folder \"" + dir + "\"");
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (mkdir(dir.c_str(), 0777) == -1) {
|
||||
if (errno == EEXIST) {
|
||||
// Try to open as a folder (might be a file / symbolic link)
|
||||
DIR *dirp = opendir(dir.c_str());
|
||||
if (dirp == NULL) {
|
||||
error("Could not create folder \"" + dir + "\"");
|
||||
} else {
|
||||
// The folder exists, just close the stream and return
|
||||
closedir(dirp);
|
||||
}
|
||||
} else {
|
||||
error("Could not create folder \"" + dir + "\"");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the specified directory against files, which should be included
|
||||
* in the project files. It will not include files present in the exclude list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue