Skip to content

Instantly share code, notes, and snippets.

@fwextensions
Created December 15, 2012 23:42
Show Gist options
  • Save fwextensions/4300987 to your computer and use it in GitHub Desktop.
Save fwextensions/4300987 to your computer and use it in GitHub Desktop.
The Adobe Fireworks JavaScript engine has an undocumented File class that has some useful features lacking in the documented Files object.
// to access a file, create a new instance of the File class by passing in
// a standard OS-style path to the constructor. I've only tested this on
// Windows, but a standard path on OS X should work, too.
var f = new File("C:\\test.txt");
// unlike the file references created by the Files object, these have some
// useful properties, like length, which is the file size in bytes
console.log(f.length);
// modification is the last modified date of the file, but it appears to
// have a bug, where the date is a month newer than it should be. this
// function would return the corrected date.
function getModifiedDate(
inFile)
{
var date = new Date(inFile.modified.getTime());
if (date.getMonth() == 0) {
date.setFullYear(date.getFullYear() - 1);
}
date.setMonth((date.getMonth() - 1 + 12) % 12);
return date;
}
console.log(getModifiedDate(f));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment