en:code:data:file
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | en:code:data:file [2021/02/13 11:23] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== File ====== | ||
+ | The File object allows you to read and write a file. | ||
+ | ===== Functions ===== | ||
+ | |||
+ | ==== File ==== | ||
+ | Constructor function. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | var myObject = new File(); | ||
+ | </ | ||
+ | |||
+ | === Example === | ||
+ | Create a File object. | ||
+ | <code javascript> | ||
+ | var myObject = new File(); | ||
+ | </ | ||
+ | |||
+ | ==== copy ==== | ||
+ | Copy a file. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | File.copy(source, | ||
+ | </ | ||
+ | <code javascript> | ||
+ | File.copy(source, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - source - (string) the source file to copy | ||
+ | - destination - (string) the destination file/ | ||
+ | - options - (object) [//Added in Actionaz 3.0.1.//] | ||
+ | * noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true) | ||
+ | * noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true) | ||
+ | * noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true) | ||
+ | * createDestinationDirectory - (bool) should the destination directory be created if it doesn' | ||
+ | |||
+ | === Returns === | ||
+ | * (null) nothing | ||
+ | |||
+ | === Exceptions === | ||
+ | * (ParameterCountError) incorrect parameter count | ||
+ | * (DirectoryCreationError) unable to create the destination directory (Linux only) | ||
+ | * (DirectoryDoesntExistError) the destination directory doesn' | ||
+ | * (CopyError) copy failed | ||
+ | * (CopyAbortedError) copy aborted (Windows only) | ||
+ | |||
+ | ==== move ==== | ||
+ | Move a file. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | File.move(source, | ||
+ | </ | ||
+ | <code javascript> | ||
+ | File.move(source, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - source - (string) the source file to move | ||
+ | - destination - (string) the destination file/ | ||
+ | - options - (object) [//Added in Actionaz 3.0.1.//] | ||
+ | * noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true) | ||
+ | * noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true) | ||
+ | * noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true) | ||
+ | * createDestinationDirectory - (bool) should the destination directory be created if it doesn' | ||
+ | |||
+ | === Returns === | ||
+ | * (null) nothing | ||
+ | |||
+ | === Exceptions === | ||
+ | * (ParameterCountError) incorrect parameter count | ||
+ | * (DirectoryCreationError) unable to create the destination directory (Linux only) | ||
+ | * (DirectoryDoesntExistError) the destination directory doesn' | ||
+ | * (MoveError) move failed | ||
+ | * (MoveAbortedError) move aborted (Windows only) | ||
+ | |||
+ | ==== rename ==== | ||
+ | This function is an alias of the [[# | ||
+ | |||
+ | ==== remove ==== | ||
+ | Remove a file. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | File.remove(filename); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | File.remove(filename, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - filename - (string) the file to remove | ||
+ | - options - (object) [//Added in Actionaz 3.0.1.//] | ||
+ | * noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true) | ||
+ | * noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true) | ||
+ | * noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true) | ||
+ | * allowUndo - (bool) should the file/ | ||
+ | |||
+ | === Returns === | ||
+ | * (null) nothing | ||
+ | |||
+ | === Exceptions === | ||
+ | * (ParameterCountError) incorrect parameter count | ||
+ | * (RemoveError) remove failed | ||
+ | * (RemoveAbortedError) remove aborted (Windows only) | ||
+ | |||
+ | ===== Methods ===== | ||
+ | |||
+ | ==== open ==== | ||
+ | Opens a file. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.open(filename, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - filename - (string) the filename of the file to open | ||
+ | - openMode - ([[# | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | === Exceptions === | ||
+ | * (CannotOpenFileError) cannot open the file | ||
+ | |||
+ | ==== write ==== | ||
+ | Write raw data to this File. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.write(data); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | myObject.write(other); | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - data - ([[en: | ||
+ | - other - (mixed) the data to write | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | === Exceptions === | ||
+ | * (WriteFailedError) write failed | ||
+ | |||
+ | ==== writeText ==== | ||
+ | Write text to this File. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.writeText(text); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | myObject.writeText(text, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - text - (string) the text to write | ||
+ | - encoding - ([[en: | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | === Exceptions === | ||
+ | * (WriteFailedError) write failed | ||
+ | |||
+ | ==== read ==== | ||
+ | Read raw data from this File. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.read(); | ||
+ | </ | ||
+ | |||
+ | === Returns === | ||
+ | * ([[en: | ||
+ | |||
+ | ==== readText ==== | ||
+ | Read text from this File. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.readText(); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | myObject.readText(encoding); | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - encoding - ([[en: | ||
+ | |||
+ | === Returns === | ||
+ | * (string) the text read from the file | ||
+ | |||
+ | ==== close ==== | ||
+ | Close this file. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.close(); | ||
+ | </ | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | ==== copy ==== | ||
+ | Copy this file to another location. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.copy(destination); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | myObject.copy(destination, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - destination - (string) the location where to copy the file | ||
+ | - options - (object) [//Added in Actionaz 3.0.1.//] | ||
+ | * noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true) | ||
+ | * noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true) | ||
+ | * noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true) | ||
+ | * createDestinationDirectory - (bool) should the destination directory be created if it doesn' | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | === Exceptions === | ||
+ | * (ParameterCountError) incorrect parameter count | ||
+ | * (DirectoryCreationError) unable to create the destination directory (Linux only) | ||
+ | * (DirectoryDoesntExistError) the destination directory doesn' | ||
+ | * (CopyError) copy failed | ||
+ | * (CopyAbortedError) copy aborted (Windows only) | ||
+ | |||
+ | ==== move ==== | ||
+ | Move this file to another location. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.move(destination); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | myObject.move(destination, | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - destination - (string) the location where to move the file | ||
+ | - options - (object) [//Added in Actionaz 3.0.1.//] | ||
+ | * noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true) | ||
+ | * noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true) | ||
+ | * noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true) | ||
+ | * createDestinationDirectory - (bool) should the destination directory be created if it doesn' | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | === Exceptions === | ||
+ | * (ParameterCountError) incorrect parameter count | ||
+ | * (DirectoryCreationError) unable to create the destination directory (Linux only) | ||
+ | * (DirectoryDoesntExistError) the destination directory doesn' | ||
+ | * (MoveError) move failed | ||
+ | * (MoveAbortedError) move aborted (Windows only) | ||
+ | |||
+ | ==== rename ==== | ||
+ | This method is an alias of the [[# | ||
+ | |||
+ | ==== remove ==== | ||
+ | Remove this file. | ||
+ | |||
+ | === Syntax === | ||
+ | <code javascript> | ||
+ | myObject.remove(); | ||
+ | </ | ||
+ | <code javascript> | ||
+ | myObject.remove(options); | ||
+ | </ | ||
+ | |||
+ | === Arguments === | ||
+ | - options - (object) [//Added in Actionaz 3.0.1.//] | ||
+ | * noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true) | ||
+ | * noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true) | ||
+ | * noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true) | ||
+ | * allowUndo - (bool) should the file/ | ||
+ | |||
+ | === Returns === | ||
+ | * (File) this File | ||
+ | |||
+ | === Exceptions === | ||
+ | * (ParameterCountError) incorrect parameter count | ||
+ | * (RemoveError) remove failed | ||
+ | * (RemoveAbortedError) remove aborted (Windows only) | ||
+ | |||
+ | ===== Enumerations ===== | ||
+ | |||
+ | ==== OpenMode ==== | ||
+ | File open mode. | ||
+ | |||
+ | === Values === | ||
+ | - ReadOnly: file opened for reading only | ||
+ | - WriteOnly: file opened for writing only | ||
+ | - ReadWrite: file opened for reading and writing | ||
+ | - Append: file opened for writing at the end of the file | ||
+ | - Truncate: file opened for writing, erases any previous content | ||
+ | - Text: file opened in text mode | ||
+ | - Unbuffered: file opened in unbuffered mode | ||
+ | |||
+ | === Notes === | ||
+ | This is a flag enumeration, | ||
+ | Example: | ||
+ | <code javascript> | ||
+ | myObject.open(" | ||
+ | </ |