|
@@ -1,8 +1,6 @@
|
|
|
#include "pathcreator.h"
|
|
|
|
|
|
-#include <unistd.h>
|
|
|
#include <sys/types.h>
|
|
|
-#include <sys/stat.h>
|
|
|
#include <time.h>
|
|
|
#include <stdint.h>
|
|
|
#include <stdio.h>
|
|
@@ -92,3 +90,26 @@ bool PathCreator::CreateDatePath(std::string root, bool add_time)
|
|
|
}
|
|
|
return Mkdir(buf);
|
|
|
}
|
|
|
+
|
|
|
+bool PathCreator::IsPathExist(const std::string& path) {
|
|
|
+ if (access(path.c_str(), 0) == F_OK) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+bool PathCreator::IsFile(const std::string& path) {
|
|
|
+ if (!IsPathExist(path)) {
|
|
|
+ printf("%s:%d %s not exist\n", __FILE__, __LINE__, path.c_str());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ struct stat buffer;
|
|
|
+ return (stat(path.c_str(), &buffer) == 0 && S_ISREG(buffer.st_mode));
|
|
|
+}
|
|
|
+
|
|
|
+bool PathCreator::IsFolder(const std::string& path) {
|
|
|
+ if (!IsPathExist(path)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ struct stat buffer;
|
|
|
+ return (stat(path.c_str(), &buffer) == 0 && S_ISDIR(buffer.st_mode));
|
|
|
+}
|