Skip to content

File System API Migration

Peter Flynn edited this page Oct 8, 2013 · 31 revisions

Here are the API changes that will result from the [File System Evolution](File System) plan:

Old API New API Suggested action Usage
FileUtils.readAsText(fileEntry) FileUtils.readAsText(file) Already drop-in compatible 13
FileUtils.writeText(fileEntry) FileUtils.writeText(file) Already drop-in compatible 5
FileIndexManager.getFileInfoList("all")
FileIndexManager.getFileInfoList("...")
filesystem.getFileList()
filesystem.getFileList(filter)
_Note: returns an array of actual Files, but they provide the same properties as the old FileInfos)_
Shim with deprecation warning 7
FileIndexManager.getFilenameMatches("...", filename) filesystem.getFileList(filter) Shim with deprecation warning None
ProjectManager.shouldShow(entry) filesystem.shouldShow(fullPath) Leave old API in place permanently None?
ProjectManager.isBinaryFile(name/fullPath) ??? Shim with deprecation warning. New API on LanguageManager. None
new NativeFileSystem.FileEntry(fullPath)
new NativeFileSystem.DirectoryEntry(fullPath)
filesystem.getFileForPath(fullPath)
filesystem.getDirectoryForPath(fullPath)
Shim with deprecation warning 19
DirectoryEntry.getFile(relpath) filesystem.resolve(path) Do not shim (callers will break right away) 4
NativeFileSystem.resolveNativeFileSystemPath(fullPath) filesystem.resolve(path) Shim with deprecation warning 4
NativeFileSystem.requestNativeFileSystem(fullPath)... fs.root filesystem.resolve(fullPath) Shim with deprecation warning 6
Concatenation: folderPath + "/" + filename (same) Normalize paths on ingest to allow this
Concatenation: folderPath + filename folderPath + "/" + filename Change all directory paths to end in "/" to allow this Unclear, but at least several
Substrings: relpath = fullPath.slice(dirFullPath.length) relpath = fullPath.slice(dirFullPath.length + 1) (Above change removes this diff too)
entry.isFile, entry.isDirectory entry.isFile(), entry.isDirectory() Change API to use a read-only property (like fullPath) 9
NativeFileSystem.showOpenDialog()
NativeFileSystem.showSaveDialog()
filesystem.showOpenDialog()
filesystem.showSaveDialog()
Shim with deprecation warning 4
fileEntry.getMetadata() file.stat()
_TODO: document change in data structure too_
Do not shim (callers will break right away) 1
fileEntry.createWriter()... writer.write(text) file.write(text) Do not shim (callers will break right away) 5, but only used in 2
fileEntry.file()... new NativeFileSystem.FileReader().readAsText(fileResult) file.readAsText() Do not shim (callers will break right away) None
directoryEntry.createReader().readEntries() directory.getContents() ??? Do not shim (callers will break right away) 5
DirectoryEntry.getFile(relpath, {create:true}) filesystem.getFileForPath(fullPath).write("")
Note: as a result, this can fold in writeText() or createWriter()/write() calls that used to immediately follow the getFile() call.
Do not shim (callers will break right away)
TODO: add a cleaner create() API?
2
DirectoryEntry.getDirectory(relpath, {create:true}) filesystem.getDirectoryForPath(fullPath).create() Do not shim (callers will break right away) 2
instanceof NativeFileSystem.InaccessibleFileEntry instanceof InMemoryFile Do not shim (callers will break right away) 1(ish)
entry.remove() entry.moveToTrash() Do not shim (callers will break right away) None
brackets.fs.makedir(fullPath, mode) filesystem.getDirectoryForPath(fullPath).create() Do not shim (callers will break right away) 1
brackets.fs.unlink(fullPath) entry.unlink() Do not shim (callers will break right away) None
brackets.fs.rename(oldFullPath, newFullPath) entry.rename(newFullPath)
(NOTE: Exact semantics of this call are still a bit TBD).
Do not shim (callers will break right away) None
brackets.fs.chmod() ??? Do not shim (callers will break right away) None
new NativeFileSystem.InaccessibleFileEntry(fakePath) filesystem.getInMemoryFile(fakePath) Do not shim (callers will break right away) None
old new action

"Usage" = how many extensions currently use the API

Extensions that will break

The following extensions use at least one API in the "Do not shim (callers will break right away)" category:

  • ...
Clone this wiki locally