mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Remove $native.write()
This commit is contained in:
parent
6abf1ff1aa
commit
5202e846de
@ -24,7 +24,7 @@ namespace v8_extensions {
|
||||
|
||||
void Native::CreateContextBinding(CefRefPtr<CefV8Context> context) {
|
||||
const char* methodNames[] = {
|
||||
"read", "write", "absolute",
|
||||
"read", "absolute",
|
||||
"remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath",
|
||||
"getWatchedPaths", "unwatchAllPaths", "move", "moveToTrash", "reload",
|
||||
"md5ForPath", "getPlatform", "setWindowState", "getWindowState", "isMisspelled",
|
||||
@ -70,32 +70,6 @@ namespace v8_extensions {
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "write") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
NSString *content = stringFromCefV8Value(arguments[1]);
|
||||
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
// Create parent directories if they don't exist
|
||||
BOOL exists = [fm fileExistsAtPath:[path stringByDeletingLastPathComponent] isDirectory:nil];
|
||||
if (!exists) {
|
||||
[fm createDirectoryAtPath:[path stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
BOOL success = [content writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error];
|
||||
|
||||
if (error) {
|
||||
exception = [[error localizedDescription] UTF8String];
|
||||
}
|
||||
else if (!success) {
|
||||
std::string exception = "Cannot write to '";
|
||||
exception += [path UTF8String];
|
||||
exception += "'";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "absolute") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
"dependencies": {
|
||||
"coffee-script": "1.5",
|
||||
"ctags": "0.1.0",
|
||||
"oniguruma": "0.4.0"
|
||||
"oniguruma": "0.4.0",
|
||||
"mkdirp": "0.3.5"
|
||||
},
|
||||
|
||||
"scripts": {
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
_ = require 'underscore'
|
||||
nodeFs = nodeRequire 'fs'
|
||||
mkdirp = nodeRequire 'mkdirp'
|
||||
|
||||
module.exports =
|
||||
# Make the given path absolute by resolving it against the
|
||||
@ -102,7 +103,8 @@ module.exports =
|
||||
|
||||
# Open, write, flush, and close a file, writing the given content.
|
||||
write: (path, content) ->
|
||||
$native.write(path, content)
|
||||
mkdirp.sync(@directory(path))
|
||||
nodeFs.writeFileSync(path, content)
|
||||
|
||||
makeDirectory: (path) ->
|
||||
nodeFs.mkdirSync(path)
|
||||
|
Loading…
Reference in New Issue
Block a user