Skip to content
kerrishotts edited this page Nov 15, 2012 · 5 revisions

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.

Persistent and Temporary Storage

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.

Properties

  • PKFILE.consoleLogging
  • PKFILE.persistentFS
  • PKFILE.persistentFSName
  • PKFILE.temporaryFS
  • PKFILE.temporaryFSName

Methods

*nix Convenience Methods

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()

Version

0.1 Introduced

0.2 Docs Valid

Clone this wiki locally