mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +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) {
|
void Native::CreateContextBinding(CefRefPtr<CefV8Context> context) {
|
||||||
const char* methodNames[] = {
|
const char* methodNames[] = {
|
||||||
"read", "write", "absolute",
|
"read", "absolute",
|
||||||
"remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath",
|
"remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath",
|
||||||
"getWatchedPaths", "unwatchAllPaths", "move", "moveToTrash", "reload",
|
"getWatchedPaths", "unwatchAllPaths", "move", "moveToTrash", "reload",
|
||||||
"md5ForPath", "getPlatform", "setWindowState", "getWindowState", "isMisspelled",
|
"md5ForPath", "getPlatform", "setWindowState", "getWindowState", "isMisspelled",
|
||||||
@ -70,32 +70,6 @@ namespace v8_extensions {
|
|||||||
|
|
||||||
return true;
|
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") {
|
else if (name == "absolute") {
|
||||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"coffee-script": "1.5",
|
"coffee-script": "1.5",
|
||||||
"ctags": "0.1.0",
|
"ctags": "0.1.0",
|
||||||
"oniguruma": "0.4.0"
|
"oniguruma": "0.4.0",
|
||||||
|
"mkdirp": "0.3.5"
|
||||||
},
|
},
|
||||||
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
_ = require 'underscore'
|
_ = require 'underscore'
|
||||||
nodeFs = nodeRequire 'fs'
|
nodeFs = nodeRequire 'fs'
|
||||||
|
mkdirp = nodeRequire 'mkdirp'
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
# Make the given path absolute by resolving it against the
|
# 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.
|
# Open, write, flush, and close a file, writing the given content.
|
||||||
write: (path, content) ->
|
write: (path, content) ->
|
||||||
$native.write(path, content)
|
mkdirp.sync(@directory(path))
|
||||||
|
nodeFs.writeFileSync(path, content)
|
||||||
|
|
||||||
makeDirectory: (path) ->
|
makeDirectory: (path) ->
|
||||||
nodeFs.mkdirSync(path)
|
nodeFs.mkdirSync(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user