From 4bc513a8e3148564c566f8699a6f4e5ea2d2a842 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 7 Mar 2013 17:55:13 -0800 Subject: [PATCH] Remove $native.isFile() and $native.isDirectory --- native/v8_extensions/native.mm | 22 ++-------------------- src/stdlib/fs.coffee | 7 +++---- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/native/v8_extensions/native.mm b/native/v8_extensions/native.mm index c1df19b42..5ba1e6fe2 100644 --- a/native/v8_extensions/native.mm +++ b/native/v8_extensions/native.mm @@ -24,8 +24,8 @@ namespace v8_extensions { void Native::CreateContextBinding(CefRefPtr context) { const char* methodNames[] = { - "exists", "read", "write", "absolute", "isDirectory", - "isFile", "remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath", + "exists", "read", "write", "absolute", + "remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath", "getWatchedPaths", "unwatchAllPaths", "makeDirectory", "move", "moveToTrash", "reload", "lastModified", "md5ForPath", "getPlatform", "setWindowState", "getWindowState", "isMisspelled", "getCorrectionsForMisspelling" @@ -113,24 +113,6 @@ namespace v8_extensions { return true; } - else if (name == "isDirectory") { - NSString *path = stringFromCefV8Value(arguments[0]); - - BOOL isDir = false; - BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]; - retval = CefV8Value::CreateBool(exists && isDir); - - return true; - } - else if (name == "isFile") { - NSString *path = stringFromCefV8Value(arguments[0]); - - BOOL isDir = false; - BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]; - retval = CefV8Value::CreateBool(exists && !isDir); - - return true; - } else if (name == "remove") { NSString *path = stringFromCefV8Value(arguments[0]); diff --git a/src/stdlib/fs.coffee b/src/stdlib/fs.coffee index e36212e66..be2951ef8 100644 --- a/src/stdlib/fs.coffee +++ b/src/stdlib/fs.coffee @@ -50,13 +50,12 @@ module.exports = # Returns true if the file specified by path exists and is a # directory. isDirectory: (path) -> - $native.isDirectory path + path? and nodeFs.existsSync(path) and nodeFs.statSync(path).isDirectory() # Returns true if the file specified by path exists and is a # regular file. isFile: (path) -> - return false unless path? - $native.isFile(path) + path? and nodeFs.existsSync(path) and nodeFs.statSync(path).isFile() # Returns an array with all the names of files contained # in the directory path. @@ -118,7 +117,7 @@ module.exports = @makeDirectory(path) traverseTree: (rootPath, onFile, onDirectory) -> - return unless nodeFs.existsSync(rootPath) and nodeFs.statSync(rootPath).isDirectory() + return unless @isDirectory(rootPath) traverse = (rootPath, prefix, onFile, onDirectory) => prefix = "#{prefix}/" if prefix