summaryrefslogtreecommitdiff
path: root/utils/filelib.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2011-10-20 02:31:25 +0200
committerPatrick Simianer <p@simianer.de>2011-10-20 02:31:25 +0200
commit92e48b652530d2d2bb4f2694501f95a60d727cb2 (patch)
treeb484bd0c4216525690de8b14fb654c9581a300c2 /utils/filelib.cc
parent0e70073cec6cdcafaf60d4fbcbd1adf82ae21c8e (diff)
parent082b6c77e0703ccd1c85947828c33d4b0eef20f0 (diff)
finalized merge
Diffstat (limited to 'utils/filelib.cc')
-rw-r--r--utils/filelib.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/utils/filelib.cc b/utils/filelib.cc
index 79ad2847..d206fc19 100644
--- a/utils/filelib.cc
+++ b/utils/filelib.cc
@@ -2,6 +2,12 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <cstdlib>
+#include <cstdio>
+#include <sys/stat.h>
+#include <sys/types.h>
using namespace std;
@@ -20,3 +26,28 @@ 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();
+ }
+}
+
+#if 0
+void CopyFile(const string& inf, const string& outf) {
+ WriteFile w(outf);
+ CopyFile(inf,*w);
+}
+#else
+void CopyFile(const string& inf, const string& outf) {
+ ofstream of(outf.c_str(), fstream::trunc|fstream::binary);
+ ifstream in(inf.c_str(), fstream::binary);
+ of << in.rdbuf();
+}
+#endif
+