From fedf43ca0a33fa55aba70976f864122365a37463 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 7 Mar 2013 17:57:28 -0800 Subject: [PATCH] Remove $native.exists() --- native/v8_extensions/native.mm | 11 ++--------- src/stdlib/fs.coffee | 7 +++---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/native/v8_extensions/native.mm b/native/v8_extensions/native.mm index 5ba1e6fe2..63f520d1f 100644 --- a/native/v8_extensions/native.mm +++ b/native/v8_extensions/native.mm @@ -24,7 +24,7 @@ namespace v8_extensions { void Native::CreateContextBinding(CefRefPtr context) { const char* methodNames[] = { - "exists", "read", "write", "absolute", + "read", "write", "absolute", "remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath", "getWatchedPaths", "unwatchAllPaths", "makeDirectory", "move", "moveToTrash", "reload", "lastModified", "md5ForPath", "getPlatform", "setWindowState", "getWindowState", "isMisspelled", @@ -49,14 +49,7 @@ namespace v8_extensions { CefRefPtr& retval, CefString& exception) { @autoreleasepool { - if (name == "exists") { - std::string cc_value = arguments[0]->GetStringValue().ToString(); - const char *path = cc_value.c_str(); - retval = CefV8Value::CreateBool(access(path, F_OK) == 0); - - return true; - } - else if (name == "read") { + if (name == "read") { NSString *path = stringFromCefV8Value(arguments[0]); NSError *error = nil; diff --git a/src/stdlib/fs.coffee b/src/stdlib/fs.coffee index be2951ef8..657193d76 100644 --- a/src/stdlib/fs.coffee +++ b/src/stdlib/fs.coffee @@ -27,8 +27,7 @@ module.exports = # Returns true if the file specified by path exists exists: (path) -> - return false unless path? - $native.exists(path) + path? and nodeFs.existsSync(path) # Returns the extension of a file. The extension of a file is the # last dot (excluding any number of initial dots) followed by one or @@ -50,12 +49,12 @@ module.exports = # Returns true if the file specified by path exists and is a # directory. isDirectory: (path) -> - path? and nodeFs.existsSync(path) and nodeFs.statSync(path).isDirectory() + @exists(path) and nodeFs.statSync(path).isDirectory() # Returns true if the file specified by path exists and is a # regular file. isFile: (path) -> - path? and nodeFs.existsSync(path) and nodeFs.statSync(path).isFile() + @exists(path) and nodeFs.statSync(path).isFile() # Returns an array with all the names of files contained # in the directory path.