new $.oFile(path)
openHarmony/openHarmony_file.js, line 502
The $.oFile helper class -- providing utilities for file manipulation and access.
Name | Type | Description |
---|---|---|
path |
string | The path to the file. |
Properties:
Name | Type | Description |
---|---|---|
path |
string | The path to the file. |
Members
-
existsbool
-
Whether the file exists already.
-
extensionstring
-
The extension of the file.
-
folder$.oFolder
-
The folder containing the file.
-
fullNamestring
-
The name of the file with extension.
-
namestring
-
The name of the file without extenstion.
-
pathstring
-
The path of the file. Setting a path doesn't move the file, only changes where the file object is pointing.
-
readonlytoonboomPathstring
-
The path of the file encoded as a toonboom relative path.
-
readonlytoonboomPathstring
-
The path of the file encoded as a toonboom relative path.
Methods
-
copy(folder, copyName, overwrite)
openHarmony/openHarmony_file.js, line 747 -
Copies the file to the folder.
Name Type Default Description folder
string optional Content to write to the file. copyName
string optional Name of the copied file without the extension. If not specified, the copy will keep its name unless another file is present in which case it will be called "_copy" overwrite
bool false optional Whether to overwrite the file. -
move(folder, overwrite)
openHarmony/openHarmony_file.js, line 681 -
Moves the file to the specified path.
Name Type Default Description folder
string destination folder for the file. overwrite
bool false optional Whether to overwrite the file. -
moveToFolder(folder, overwrite)
openHarmony/openHarmony_file.js, line 716 -
Moves the file to the folder.
Name Type Default Description folder
string destination folder for the file. overwrite
bool false optional Whether to overwrite the file. -
parseAsXml()
openHarmony/openHarmony_file.js, line 808 -
Parses the file as a XML and returns an object containing the values.
Example
// parses the xml file as an object with imbricated hierarchy. // each xml node is represented by a simple object with a "children" property containing the children nodes, // and a objectName property representing the name of the node. // If the node has attributes, those are set as properties on the object. All values are set as strings. // example: parsing the shortcuts file var shortcutsFile = (new $.oFile(specialFolders.userConfig+"/shortcuts.xml")).parseAsXml(); // The returned object will always be a simple document object with a single "children" property containing the document nodes. var shortcuts = shortcuts.children[0].children // children[0] is the "shortcuts" parent node, we want the nodes contained within for (var i in shortcuts){ log (shortcuts[i].id) }
-
read()
openHarmony/openHarmony_file.js, line 635 -
Reads the content of the file.
-
remove()
openHarmony/openHarmony_file.js, line 781 -
Removes the file.
-
rename(newName, overwrite)
openHarmony/openHarmony_file.js, line 731 -
Renames the file.
Name Type Default Description newName
string the new name for the file, without the extension. overwrite
bool false optional Whether to replace a file of the same name if it exists in the folder. -
toString(){string}
openHarmony/openHarmony_file.js, line 822 -
Used in converting the file to a string value, provides the string-path.
Returns:
Type Description string The file path's as a string. -
write(content, append)
openHarmony/openHarmony_file.js, line 657 -
Writes to the file.
Name Type Default Description content
string Content to write to the file. append
bool false optional Whether to append to the file.