Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/util/system.cpp b/util/system.cpp
index 86ffa4b6..d9ab6e18 100644
--- a/util/system.cpp
+++ b/util/system.cpp
@@ -1,55 +1,67 @@
#include <string>
#include "system.h"
#include <stdint.h>
#ifndef WINDOWS
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#endif
#ifndef WINDOWS
static bool isReadable(const std::string & path){
#ifndef WII
if (access(path.c_str(), R_OK) == 0){
return true;
} else {
return false;
}
#else
/* FIXME */
return true;
#endif
}
bool System::isDirectory(const std::string & path){
struct stat info;
if (stat(path.c_str(), &info) == 0){
if (S_ISDIR(info.st_mode) == 1){
return true;
} else {
return false;
}
}
return false;
}
bool System::readableFile(const std::string & path){
return isReadable(path) && ! isDirectory(path);
}
bool System::readable(const std::string & path){
return isReadable(path);
}
void System::makeDirectory(const std::string & path){
mkdir(path.c_str(), 0777);
}
uint64_t System::currentMicroseconds(){
struct timeval hold;
gettimeofday(&hold, NULL);
return hold.tv_sec * 1000 * 1000 + hold.tv_usec;
}
#endif
+
+void System::makeAllDirectory(const std::string & path){
+ unsigned int last = path.find('/');
+ while (last != std::string::npos){
+ std::string sofar = path.substr(0, last);
+ if (sofar != ""){
+ makeDirectory(sofar);
+ }
+ last = path.find('/', last + 1);
+ }
+ makeDirectory(path);
+}
diff --git a/util/system.h b/util/system.h
index 16291d3b..3ecbb1c9 100644
--- a/util/system.h
+++ b/util/system.h
@@ -1,17 +1,18 @@
#ifndef _paintown_system_h
#define _paintown_system_h
/* system utilities */
#include <string>
#include <stdint.h>
namespace System{
bool isDirectory(const std::string & path);
void makeDirectory(const std::string & path);
+ void makeAllDirectory(const std::string & path);
bool readableFile(const std::string & path);
bool readable(const std::string & path);
uint64_t currentMicroseconds();
}
#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 12:09 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68965
Default Alt Text
(2 KB)

Event Timeline