You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 26, 2019. It is now read-only.
frenzylabs edited this page Dec 14, 2010
·
2 revisions
CoreJS offers File I/O using an object for handling one file instance at a time, and offers several global, simplified methods for working with files.
Global Methods:
// Read a file:varfileContents=readFile("/path/to/file");// Write a file: (On success returns true, throws an error on failurewriteFile("/path/to/file","this is the contents i want in the file");// Remove a file:removeFile("/path/to/file");// Test if an item is a file:if(isFile("/path/to/something"){// Is file, we good}
File Object usage:
File object uses the same rules for opening a file as C, php, and others.
// Create a new File object:varfile=newFile();// Open the file for reading and writingfile.open("/path/to/file","w+r");// Write a string to the file.file.write("This is a test");// Read the file's contentsvarfileContents=file.read();// Get the file's pathvarcurrentFilePath=file.getFilePath();// Close the file.file.close();