Utility object for simple filesystem access.
var file = new Jaxer.File(path);
Creates a new instance for performing filesystem file operations.
Checks 'end of file' status and returns boolean to indicate whether the end of file has been reached. This function takes no arguments but needs an open read mode filehandle.
Returns the extension of the file object.
Returns the current byte position in the referenced file. This method is only applicable when using the File.read() method. If used with the File.readline() method it will return the internal read ahead buffer position, which is unlikely to be what was expected.
Returns the size in bytes of the referenced file system object as reported by the OS..
Return a new instance of a JSLib File object referencing the same path.
Closes an open file stream.
<String> path - the path to copy the file to.
Copy to file to another location.
var p='/tmp/foo.dat'; var f=new Jaxer.File(p); f.copy("/tmp/foo_copy.dat");
Creates a new file under the referenced path of the object.
Creates a new unique file under the referenced path of the object.
- <String> mode - an argument of string 'w', 'a', 'r', 'b'
- <permission> permission - a number containing the unix style chmod value for the permissions
Opens the file for reading or writing. The provided file mode can be one or two characters the using 'rb','ab','wb' will cause the file to be opened in binary safe mode. NOTE: This implementation doesn't support file locking so will allow multiple open handles to the same file.
<Number> size - Number of bytes to read
Either a string or array of bytes depending on 'r' or 'rb' mode.
Reads a file (that's already been opened) and returns its contents. Returns a null on failure.
Returns an array of individual lines read from the file on success, throws an Exception on failure.
Reads a single line from an open file, takes no arguments but needs an open read mode filehandle returns string containing the data read on success, null on failure.
Removes the referenced file object from the file system. Throws an exception is the action fails.
Truncates the file. Throws an exception if the action fails.
<Array> data - Either a String for 'w' or an array of bytes for 'wb'
Write provided data to a file.
var p='/tmp/foo.dat'; var f=new Jaxer.File(p); f.open('w'); f.write("some data to be written"); f.close();