-
Notifications
You must be signed in to change notification settings - Fork 29
PKFILE
PKFILE
(in framework/fileutil.js) provides various File utilities.
This library includes routines to deal with the FILE API, (which is... a bit painful.) The purpose of the library is to reduce the amount of work necessary to go through obtaining a file system, working with directories and files, etc. That isn't to say that we can eliminate callbacks or even callback chaining -- but it is significantly easier without all the intervening cruft, which is essentially (for all intents and purposes) boilerplate.
This library provides various conveniences that make referencing persistent and temporary storage a bit easier as well. For example, you can use a path like the following:
doc://photo.jpg --> /some/gobbledygook/yourApp/Documents/photo.jpg
tmp://photo.jpg --> /some/gobbledygook/yourApp/tmp/photo.jpg
Several APIs (such as camera capture) may also refer to paths with "file://localhost" attached. The routines will gracefully remove this so that the reference is a true file.
- version
- PKFILE.consoleLogging - if
true
, allows logging to the console. - PKFILE.persistentFS - Internal only. Points to the persistent storage file system.
- PKFILE.persistentFSName - Internal only. The name of the persistent storage file system.
- PKFILE.temporaryFS - Internal only. Points to the temporary storage file system.
- PKFILE.temporaryFSName - Internal only. The name of the temporary storage file system. Note: the above four properties are initialized automatically when the first PKFILE method is used.
- PKFILE.copyFileTo ( source, target, success, failure )
- PKFILE.moveFileTo ( source, target, success, failure )
- PKFILE.renameFile ( source, newName, success, failure )
- PKFILE.removeFile ( theFile, success, failure )
- PKFILE.createFileWriter ( theFile, success, failure )
- PKFILE.writeFileData ( writer, theData, success, failure )
- PKFILE.getListing - Not implemented
- PKFILE.createDirectory - Not implemented
- PKFILE.removeDirectory - Not implemented
- PKFILE.createFileReader - Not implemented
- PKFILE.readFileData - Not implemented
For those who are more comfortable with *nix/BSD commands, nearly each method has a version that correlates to a roughly *nix name. The parameters are the same, however.
METHODS
copyFileTo ( source, target, success, failure ) ==> cp ()
moveFileTo ( source, target, success, failure ) ==> mv ()
removeFile ( theFile, success, failure ) ==> rm ()
renameFile ( source, newName, success, failure )
createFileWriter ( theFile, success, failure ) ==> fcreate ()
writeFileData ( writer, theData, success, failure ) ==> fwrite ()
PLANNED METHODS
getListing ( path, filters, success, failure ) ==> ls ()
createDirectory ( path, newDirectory, success, failure ) ==> mkdir()
removeDirectory ( path, theDirectory, success, failure ) ==> rmdir()
createFileReader ( theFile, success, failure ) ==> fopen()
readFileData ( reader, success, failure ) ==> fread()
0.1 Introduced
0.3 +version, Docs Valid