mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add Buffer.save
This commit is contained in:
@@ -7,9 +7,18 @@ class Buffer
|
||||
url: null
|
||||
|
||||
constructor: (@url) ->
|
||||
text = if @url then fs.read(@url) else ""
|
||||
text = if @url and fs.exists(@url)
|
||||
fs.read(@url)
|
||||
else
|
||||
""
|
||||
@aceDocument = new Document text
|
||||
|
||||
getText: ->
|
||||
@aceDocument.getValue()
|
||||
|
||||
setText: (text) ->
|
||||
@aceDocument.setValue text
|
||||
|
||||
save: ->
|
||||
if not @url then throw new Error("Tried to save buffer with no url")
|
||||
fs.write @url, @getText()
|
||||
|
||||
@@ -25,4 +25,3 @@ class Editor
|
||||
getAceSession: ->
|
||||
@aceEditor.getSession()
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,12 @@ module.exports =
|
||||
listDirectoryTree: (path) ->
|
||||
@list path, true
|
||||
|
||||
# Remove a file at the given path. Throws an error if path is not a
|
||||
# file or a symbolic link to a file.
|
||||
remove: (path) ->
|
||||
fm = OSX.NSFileManager.defaultManager
|
||||
paths = fm.removeItemAtPath_error path, null
|
||||
|
||||
# Open, read, and close a file, returning the file's contents.
|
||||
read: (path) ->
|
||||
path = @absolute path
|
||||
|
||||
Reference in New Issue
Block a user