mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add fs.makeDirectory
This commit is contained in:
@@ -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;
|
||||
};
|
||||
@@ -66,6 +66,9 @@ module.exports =
|
||||
write: (path, content) ->
|
||||
$native.write(path, content)
|
||||
|
||||
makeDirectory: (path) ->
|
||||
$native.makeDirectory(path)
|
||||
|
||||
async:
|
||||
list: (path) ->
|
||||
deferred = $.Deferred()
|
||||
|
||||
Reference in New Issue
Block a user