Add fs.makeDirectory

This commit is contained in:
Corey Johnson
2012-04-26 16:26:49 -07:00
parent f37017b94c
commit fbcd8e43a0
2 changed files with 16 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ NSString *stringFromCefV8Value(const CefRefPtr<CefV8Value>& value) {
NativeHandler::NativeHandler() : CefV8Handler() {
m_object = CefV8Value::CreateObject(NULL);
const char *functionNames[] = {"exists", "read", "write", "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools", "newWindow", "saveDialog", "exit", "watchPath", "unwatchPath"};
const char *functionNames[] = {"exists", "read", "write", "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools", "newWindow", "saveDialog", "exit", "watchPath", "unwatchPath", "makeDirectory"};
NSUInteger arrayLength = sizeof(functionNames) / sizeof(const char *);
for (NSUInteger i = 0; i < arrayLength; i++) {
const char *functionName = functionNames[i];
@@ -308,6 +308,18 @@ bool NativeHandler::Execute(const CefString& name,
return true;
}
else if (name == "makeDirectory") {
NSString *path = stringFromCefV8Value(arguments[0]);
NSFileManager *fm = [NSFileManager defaultManager];
NSError *error = nil;
[fm createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:&error];
if (error) {
exception = [[error localizedDescription] UTF8String];
}
return true;
}
return false;
};

View File

@@ -66,6 +66,9 @@ module.exports =
write: (path, content) ->
$native.write(path, content)
makeDirectory: (path) ->
$native.makeDirectory(path)
async:
list: (path) ->
deferred = $.Deferred()