summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-07-12 22:34:34 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2011-07-12 22:34:34 -0400
commit5e3c68b62dd72255db95c5822835a3931770f285 (patch)
treed36114a508ca7c1c1e581e73e29dd208e3177e78 /utils
parent79899fe98e2a7e4d250a8518b8a4cd8f2bb93522 (diff)
debugged pro trainer
Diffstat (limited to 'utils')
-rw-r--r--utils/filelib.cc12
-rw-r--r--utils/filelib.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/utils/filelib.cc b/utils/filelib.cc
index 79ad2847..a0969b1a 100644
--- a/utils/filelib.cc
+++ b/utils/filelib.cc
@@ -20,3 +20,15 @@ bool DirectoryExists(const string& dir) {
return false;
}
+void MkDirP(const string& dir) {
+ if (DirectoryExists(dir)) return;
+ if (mkdir(dir.c_str(), 0777)) {
+ perror(dir.c_str());
+ abort();
+ }
+ if (chmod(dir.c_str(), 07777)) {
+ perror(dir.c_str());
+ abort();
+ }
+}
+
diff --git a/utils/filelib.h b/utils/filelib.h
index dda98671..a8622246 100644
--- a/utils/filelib.h
+++ b/utils/filelib.h
@@ -12,6 +12,7 @@
bool FileExists(const std::string& file_name);
bool DirectoryExists(const std::string& dir_name);
+void MkDirP(const std::string& dir_name);
// reads from standard in if filename is -
// uncompresses if file ends with .gz