Class com.gContactSync.FileIO
Defined in: FileIO.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A class for reading, writing, and appending to files with an nsIFile for
storing data, authentication info, and logs.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
com.gContactSync.FileIO.fileNames
File names
|
<static> |
com.gContactSync.FileIO.mLogFile
An nsIFile where the log is written
|
Method Attributes | Method Name and Description |
---|---|
<static> |
com.gContactSync.FileIO.appendToFile(aFile, aData)
Appends the string aData to the nsIFile aFile.
|
<static> |
com.gContactSync.FileIO.checkDirectory(aDirectory)
Checks that a directory corresponding to an nsIFile exists, and creates it
if necessary.
|
<static> |
com.gContactSync.FileIO.checkFile(aFile, aCaller)
Checks that an argument is not null, is an instance of nsIFile, and that,
if it exists, that it is a file (not a directory).
|
<static> |
com.gContactSync.FileIO.copyFile(aSrc, aDest)
Copies the contents of one file to another using the readFile and writeFile
methods of this class.
|
<static> |
com.gContactSync.FileIO.getFileInExtDir(aName)
Gets the the file in the extension's directory with the given name.
|
<static> |
com.gContactSync.FileIO.getProfileDirectory()
Returns an nsIFile of the current profile directory of the application.
|
<static> |
com.gContactSync.FileIO.init()
Initializes the files contained in this class.
|
<static> |
com.gContactSync.FileIO.readFile(aFile)
Opens the given file and returns an array of the lines within it.
|
<static> |
com.gContactSync.FileIO.writeToFile(aFile, aData)
Writes the string data to the nsIFile aFile.
|
Class Detail
com.gContactSync.FileIO()
A class for reading, writing, and appending to files with an nsIFile for
storing data, authentication info, and logs.
Field Detail
<static>
com.gContactSync.FileIO.fileNames
File names
<static>
com.gContactSync.FileIO.mLogFile
An nsIFile where the log is written
Method Detail
<static>
{boolean}
com.gContactSync.FileIO.appendToFile(aFile, aData)
Appends the string aData to the nsIFile aFile.
- Parameters:
- aFile
- {nsIFile} The nsIFile to which the string is appended.
- aData
- {string} The string of data to append to the file.
- Returns:
- {boolean} True if there is no error.
<static>
com.gContactSync.FileIO.checkDirectory(aDirectory)
Checks that a directory corresponding to an nsIFile exists, and creates it
if necessary.
This will throw an error if the directory could not be created, is not a
directory, or if the directory is not writeable.
- Parameters:
- aDirectory
<static>
com.gContactSync.FileIO.checkFile(aFile, aCaller)
Checks that an argument is not null, is an instance of nsIFile, and that,
if it exists, that it is a file (not a directory).
- Parameters:
- aFile
- {nsIFile} The file to check.
- aCaller
- {string} The name of the calling method.
<static>
{boolean}
com.gContactSync.FileIO.copyFile(aSrc, aDest)
Copies the contents of one file to another using the readFile and writeFile
methods of this class.
If there is an error reading the source file, or if one or more of the
given files are invalid an error will be thrown.
NOTE: The contents of the destination file are removed permanently.
- Parameters:
- aSrc
- {nsIFile} The source file.
- aDest
- {nsIFile} The destination file. NOTE: the contents of this file before the copy will be permanently removed.
- Returns:
- {boolean} True if the copy finished successfully
<static>
{nsIFile}
com.gContactSync.FileIO.getFileInExtDir(aName)
Gets the the file in the extension's directory with the given name.
- Parameters:
- aName
- {string} The name of the file to get.
- Returns:
- {nsIFile} The file with the given name in the extension's directory.
<static>
{nsIFile}
com.gContactSync.FileIO.getProfileDirectory()
Returns an nsIFile of the current profile directory of the application.
- Returns:
- {nsIFile} The current profile directory of the application.
<static>
com.gContactSync.FileIO.init()
Initializes the files contained in this class.
Also creates the log directory, if necessary.
<static>
{array}
com.gContactSync.FileIO.readFile(aFile)
Opens the given file and returns an array of the lines within it.
- Parameters:
- aFile
- {nsIFile} The nsIFile to read.
- Returns:
- {array} An array of the lines in the file or [] if there is an error.
<static>
{boolean}
com.gContactSync.FileIO.writeToFile(aFile, aData)
Writes the string data to the nsIFile aFile.
NOTE: This will delete any existing text in the file.
- Parameters:
- aFile
- {nsIFile} The nsIFile to which the string is written.
- aData
- {string} The string of data to write to the file.
- Returns:
- {boolean} True if there is no error.