summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-25 17:11:08 -0700
committerPixel <pixel@nobis-crew.org>2011-10-25 17:11:21 -0700
commit8b1e278ef364fff2aa7d6b805353a722db1b4b89 (patch)
treef317199fd11e3c396fae4aa7e786b1c6bb7da339 /src
parent246feab29cf4696048628f0ad7d3d48cafe23f3b (diff)
Adding the FileSystem global class with mkdir, and adding the writeString method to Handles. Also preparing the inclusion of Lua by adding LuaJIT.
Diffstat (limited to 'src')
-rw-r--r--src/Handle.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Handle.cc b/src/Handle.cc
index b3458a8..0ec39be 100644
--- a/src/Handle.cc
+++ b/src/Handle.cc
@@ -6,6 +6,17 @@
#include "Handle.h"
#include "Printer.h"
+#ifdef _WIN32
+static const char * strerror_r(int errorno, char * buf, size_t bufsize) {
+#ifdef _MSVC
+ strerror_s(buf, bufsize, errorno);
+ return buf;
+#else
+ return strerror(errorno);
+#endif
+}
+#endif
+
class eioInterface : public Balau::AtStart {
public:
eioInterface() : AtStart(100) { }
@@ -159,3 +170,29 @@ off_t Balau::SeekableHandle::wtell() throw (GeneralException) {
bool Balau::SeekableHandle::isEOF() {
return m_rOffset == getSize();
}
+
+struct cbResults_t {
+ Balau::Events::Custom evt;
+ int result, errorno;
+};
+
+static int eioDone(eio_req * req) {
+ cbResults_t * cbResults = (cbResults_t *) req->data;
+ cbResults->result = req->result;
+ cbResults->errorno = req->errorno;
+ cbResults->evt.doSignal();
+ return 0;
+}
+
+int Balau::FileSystem::mkdir(const char * path) throw (GeneralException) {
+ cbResults_t cbResults;
+ eio_req * r = eio_mkdir(path, 0755, 0, eioDone, &cbResults);
+ Assert(r != 0);
+ Task::yield(&cbResults.evt);
+
+ char str[4096];
+ if (cbResults.result < 0)
+ throw GeneralException(String("Unable to create directory ") + path + ": " + strerror_r(cbResults.errorno, str, sizeof(str)) + " (err#" + cbResults.errorno + ")");
+
+ return cbResults.result;
+}