Page Updated: December 29, 2005
Latest Version: 0.1.375
Debug | Install | File I/O | RDF | Network | Sound | Utils | XUL | Zip
Home | Mailing List | Install | Source Code | Downloads | Bugs | docs | clients
STATUS: Stable

File API

Function List Example: js> load('chrome/jslib/jslib.js'); ********************* JS_LIB DEBUG IS ON ********************* js> include('chrome://jslib/content/io/file.js'); *** load: filesystem.js OK *** load: file.js OK true js> var f = new File('/tmp/foo.dat'); js>; Function and Attribute List: initPath(aPath); path; exists(); leaf; parent; permissions; dateModified; nsIFile; move(aDest); append(aLeaf); appendRelativePath(aRelPath); URL; isDir(); isWritable(); isReadable(); isHidden(); isSpecial(); isFile(); isExec(); isSymlink(); open(aMode); read(); readline(); EOF; write(aContents, aPermissions); copy(aDest); close(); create(); remove(); size; ext; help; js> f.remove(); js> f = new File('/tmp/foo.dat'); [object Object] js> f.exists(); false js> f.create(); js>'w'); true js> f.write('This is a new line #1\n'); true js> f.close(); js>; true js>; This is a new line #1 js>'a'); true js> f.write('this is a new line #2\n'); true js> f.close(); js>; true js>; This is a new line #1 this is a new line #2 js> f.close(); js> f.permissions; 644 js> f.size; 44 js> f.path; /tmp/foo.dat js> f.ext; dat js> f.move('/tmp/'); filesystem.js:move successful! true js> f.path; /tmp/ js> f.parent.path; /tmp js> f.parent.isDir(); true js> f.remove(); js> f.path; /tmp/ js> f.exists(); false js> f.create(); js> f.copy('/tmp/someNewFile.dat'); file.js:copy successful! true js> f.initPath('/tmp'); /tmp js> f.path; js> f.append('someNewFile.dat'); /tmp/someNewFile.dat js> f.exists(); true js> f.dateModified; Fri Jun 15 15:10:01 GMT-0400 (EDT) 2001 js> f.dateModified.getYear(); 101 js> f.dateModified.toLocaleString(); Fri Jun 15 15:10:01 2001 js> f.dateModified.getMonth(); 5 js> f.leaf; someNewFile.dat js> f.nsIFile.path; /tmp/someNewFile.dat js> quit();

The jslib project can be contacted through the mailing list or the member list.
Copyright © 2000-2020. All rights reserved. Terms of Use & Privacy Policy.