-
Notifications
You must be signed in to change notification settings - Fork 6
iocore
- io.convertFileToEncoding
- io.cp
- io.fileExists
- io.fileInfo
- io.getDefaultEncoding
- io.getFileEncoding
- io.gunzip
- io.gzip
- io.listFilenames
- io.listFiles
- io.mkdir
- io.mv
- io.randomAccessFile
- io.readFile
- io.readFileAsArray
- io.readFileBytes
- io.readFileGzipStream
- io.readFileStream
- io.readFileString
- io.readFileXML
- io.rename
- io.rm
- io.writeFile
- io.writeFileAsArray
- io.writeFileBytes
- io.writeFileGzipStream
- io.writeFileStream
- io.writeFileString
- io.writeFileXML
io.convertFileToEncoding(aOriginalFile, aNewFile, anEncoding)
Converts an original file into a new file using the provided enconding.
io.cp(aSourceFilePath, aTargetFilePath)
Tries to copy aSourceFilePath to aTargetFilePath preserving file attributes.
io.fileExists(aFilename) : boolean
Returns true or false to determine if aFilename exists on the filesystem.
io.fileInfo(aFilePath)
Returns a file map with filename, filepath, lastModified, createTime, lastAccess, size, permissions, isDirectory and isFile.
io.getDefaultEncoding()
Returns the current default encoding used.
io.getFileEncoding(aFile)
Tries to determine the file encoding of a given file and returns the same.
io.gunzip(anArrayOfBytes) : anObject
Uncompresses a gziped array of bytes.
io.gzip(anObject) : anArrayOfBytes
Compresses an object into an array of bytes.
io.listFilenames(aFilePath, fullPath)
Returns a files array with a map with filepath (if fullPath = true) or filename otherwise.
io.listFiles(aFilePath, usePosix)
Returns a files array with a map with filename, filepath, lastModified, createTime, lastAccess, size, permissions, isDirectory and isFile for each entry on a file path. Alternatively you can specify to usePosix=true and it will add to the map the owner, group and full permissions of each file and folder.
io.mkdir(aNewDirectory) : boolean
Tries to create aNewDirectory. Returns true if successfull, false otherwise.
io.mv(aSourceFilePath, aTargetFilePath)
Tries to move aSourceFilePath to aTargetFilePath preserving file attributes.
io.randomAccessFile(aFilename, aMode) : RandomAccessFile
Creates a java RandomAccessFile to enable random access to files and returns the same.
io.readFile(aFilename, anEncoding)
Reads a file auto detecting between JSON, ParameterMap, PMap and configuration PMap, optionally providing an encoding.
Note: aFilename can contain "a.zip::afile" to read from zip files.
io.readFileAsArray(aFilename, anEncoding)
Reads a file, optionally providing a specific encoding to use, and returns an array where each line is an array element.
io.readFileBytes(aFilename)
Reads a file into an array of bytes.
Note: aFilename can contain "a.zip::afile" to read from zip files.
io.readFileGzipStream(aFilename) : JavaStream
Creates and returns a JavaStream to read from a gzip aFilename. For example:
var stream = io.readFileGzipStream("afile.txt.gz");
ioStreamRead(stream, function(buffer) { // you can also use ioStreamReadBytes
printnl(buffer);
});
stream.close();
io.readFileStream(aFilename) : JavaStream
Creates and returns a JavaStream to read aFilename. For example:
var stream = io.readFileStream("afile.txt");
ioStreamRead(stream, function(buffer) { // you can also use ioStreamReadBytes
printnl(buffer);
});
stream.close();
io.readFileString(aFilename, anEncoding)
Reads a file, optionally providing a specific encoding to use, and returns a string with the entire contents of the file.
Note: aFilename can contain "a.zip::afile" to read from zip files.
io.readFileXML(aFilename, numOfLinesToSkip, anEncoding)
Reads a file, optionally providing a specific encoding to use and/or the number of lines to skip (e.g. 1 to exclude the xml main header) and returns the contents in a XML object.
Note: aFilename can contain "a.zip::afile" to read from zip files.
io.rename(aSourceFilePath, aTargetFilePath)
Tries to rename aSourceFilePath to aTargetFilePath.
io.rm(aFilePath)
Tries to delete a file or a directory on the provided aFilePath. In case it's a directory it will try to recursively delete all directory contents.
io.writeFile(aFilename, aJSONobject, anEncoding, shouldAppend)
Writes a JSON object into the given filename, optionally with the provided encoding and/or determine if it shouldAppend to an existing file.
io.writeFileAsArray(aFilename, anArrayOfLines, anEncoding)
Writes an array of string lines into a file, optionally with the provided encoding
io.writeFileBytes(aFilename, anArrayOfBytes)
Writes an array of bytes into the given filename.
io.writeFileGzipStream(aFilename) : JavaStream
Creates and returns a JavaStream to write to a gzip aFilename. For example:
var stream = io.writeFileGzipStream("afile.txt.gz");
ioStreamWrite(stream, "Hello "); // you can also use ioStreamWriteBytes
ioStreamWrite(stream, "World!");
stream.close();
io.writeFileStream(aFilename) : JavaStream
Creates and returns a JavaStream to write to aFilename. For example:
var stream = io.writeFileStream("afile.txt");
ioStreamWrite(stream, "Hello "); // you can also use ioStreamWriteBytes
ioStreamWrite(stream, "World!");
stream.close();
io.writeFileString(aFilename, aJSONobject, anEncoding, shouldAppend)
Writes a string into the given filename, optionally with the provided encoding and/or determine if it shouldAppend to an existing file.
io.writeFileXML(aFilename, aXMLobject, anEncoding, shouldAppend)
Writes a XML object into the given filename, optionally with the provided encoding and/or determine if it shouldAppend to an existing file.