![]() |
Avidemux 2.6 Scripting Reference
|
The File class provides an interface for reading from and writing to files. More...
Public Types | |
enum | FileError { NoError = 0, ReadError = 1, WriteError = 2, FatalError = 3, ResourceError = 4, OpenError = 5, AbortError = 6, TimeOutError = 7, UnspecifiedError = 8, RemoveError = 9, RenameError = 10, PositionError = 11, ResizeError = 12, PermissionsError = 13, CopyError = 14 } |
Describes the errors that may be returned by the File.error property. More... | |
enum | OpenMode { NotOpen = 0x0000, ReadOnly = 0x0001, WriteOnly = 0x0002, ReadWrite = ReadOnly | WriteOnly, Append = 0x0004, Truncate = 0x0008, Text = 0x0010, Unbuffered = 0x0020 } |
Used with open() to describe the mode in which a file is opened. It is also returned by the File.openMode property. More... | |
enum | Permission { ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000, ReadUser = 0x0400, WriteUser = 0x0200, ExeUser = 0x0100, ReadGroup = 0x0040, WriteGroup = 0x0020, ExeGroup = 0x0010, ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001 } |
Used by the File.permission property to report the permissions and ownership of a file. More... |
Public Member Functions | |
Boolean | canReadLine () |
Returns true if a complete line of data can be read from the device; otherwise returns false. | |
void | close () |
Closes the file and sets its File.openMode to File::NotOpen. The error string is also reset. | |
Boolean | copy (String newName) |
Copies the file currently specified by File.fileName to a file called newName. | |
Boolean | exists () |
Returns true if the file specified by File.fileName exists; otherwise false. | |
File (String name) | |
Constructs a new file object to represent the file with the given name. | |
Boolean | flush () |
Flushes any buffered data to the file. | |
Boolean | link (String linkName) |
Creates a link named linkName that points to the file currently specified by File.fileName. | |
Boolean | open (OpenMode mode) |
Opens the file and sets its File.openMode to mode. | |
String | peek (Number maxSize) |
Peeks at most maxSize bytes from the file, returning the data peeked. | |
String | read (Number maxSize) |
Reads and returns at most maxSize bytes from the file. | |
String | readAll () |
Reads and returns all available data from the file. | |
String | readLine (Number maxSize=0) |
Reads and returns a line from the file but no more than maxSize characters. | |
Boolean | remove () |
Removes the file specified by File.fileName. | |
Boolean | rename (String newName) |
Renames the file currently specified by File.fileName to newName. | |
Boolean | reset () |
Seeks to the start of the file. | |
Boolean | resize (Number size) |
Sets the file size (in bytes). | |
Boolean | seek (Number pos) |
Sets the current position to pos. | |
Boolean | setPermissions (Permission permissions) |
Sets the permissions for the file to the permissions specified. | |
void | setTextModeEnabled (Boolean enabled) |
If enabled, this function sets the Text flag on the file; otherwise the Text flag is removed. | |
String | symLinkTarget () |
Returns the absolute path of the file or directory that a symlink (or shortcut on Windows) points to. An empty string is returned if the object isn't a symbolic link. | |
void | unsetError () |
Sets the file's error to File::NoError. | |
Number | write (String data) |
Writes the passed content to the file. |
Properties | |
Boolean | atEnd |
Returns true if the current read and write position is at the end of the file (i.e. there is no more data available for reading); otherwise returns false. | |
Number | bytesAvailable |
Returns the number of bytes that are available for reading. | |
Number | bytesToWrite |
For buffered devices, this function returns the number of bytes waiting to be written. For devices with no buffer, this function returns 0. | |
FileError | error |
Returns the file error status. | |
String | errorString |
Returns a human-readable description of the last file error that occurred. | |
String | fileName |
Returns the name set by the File constructor. | |
Boolean | isOpen |
Returns true if the file is open; otherwise false. | |
Boolean | isReadable |
Returns true if data can be read from the file; otherwise false. | |
Boolean | isSequential |
Returns true if this file is sequential; otherwise false. | |
Boolean | isTextModeEnabled |
Returns true if the File.Text flag is enabled; otherwise false. | |
Boolean | isWritable |
Returns true if data can be written to the file; otherwise false. | |
OpenMode | openMode |
Returns the mode in which the file has been opened; i.e. File::ReadOnly or File::WriteOnly. | |
Permission | permissions |
Returns the OR-ed combination of File::Permission for the file. | |
Number | position |
Returns the position that data is written to or read from. | |
Number | size |
Returns the size of the file. |
The File class provides an interface for reading from and writing to files.
enum FileError |
Describes the errors that may be returned by the File.error property.
enum OpenMode |
Used with open() to describe the mode in which a file is opened. It is also returned by the File.openMode property.
enum Permission |
Used by the File.permission property to report the permissions and ownership of a file.
The values may be OR-ed together to test multiple permissions and ownership values.
Boolean canReadLine | ( | ) |
Returns true if a complete line of data can be read from the device; otherwise returns false.
Note that unbuffered devices, which have no way of determining what can be read, always return false.
Boolean copy | ( | String | newName | ) |
Copies the file currently specified by File.fileName to a file called newName.
The source file is closed before it is copied.
Boolean flush | ( | ) |
Flushes any buffered data to the file.
Boolean link | ( | String | linkName | ) |
Creates a link named linkName that points to the file currently specified by File.fileName.
What a link is depends on the underlying filesystem (be it a shortcut on Windows or a symbolic link on Unix). Note: To create a valid link on Windows, linkName must have a .lnk file extension.
Boolean open | ( | OpenMode | mode | ) |
Opens the file and sets its File.openMode to mode.
String peek | ( | Number | maxSize | ) |
Peeks at most maxSize bytes from the file, returning the data peeked.
This function has no way of reporting errors; returning an empty String can mean either that no data was currently available for peeking, or that an error occurred.
Boolean remove | ( | ) |
Removes the file specified by File.fileName.
The file is closed before it is removed.
Boolean rename | ( | String | newName | ) |
Renames the file currently specified by File.fileName to newName.
The file is closed before it is renamed.
Boolean reset | ( | ) |
Seeks to the start of the file.
Boolean resize | ( | Number | size | ) |
Sets the file size (in bytes).
Note: if the specified size is larger than the file's current size then the file is truncated to 0 bytes.
Boolean seek | ( | Number | pos | ) |
Sets the current position to pos.
Boolean setPermissions | ( | Permission | permissions | ) |
Sets the permissions for the file to the permissions specified.
String symLinkTarget | ( | ) |
Returns the absolute path of the file or directory that a symlink (or shortcut on Windows) points to. An empty string is returned if the object isn't a symbolic link.
This name may not represent an existing file; it is only a string. File::exists() returns true if the symlink points to an existing file.
Number write | ( | String | data | ) |
Writes the passed content to the file.
|
read |
Returns the file error status.
The I/O device status returns an error code. For example, if open() returns false, or a read/write operation returns -1, this function can be called to find out the reason why the operation failed.
|
read |
Returns true if the file is open; otherwise false.
A file is open if it can be read from and/or written to. This property returns false if File.openMode returns File::NotOpen.
|
read |
Returns true if data can be read from the file; otherwise false.
Use bytesAvailable() to determine how many bytes can be read. This is a convenience function which checks if the File.openMode of the file contains the File::ReadOnly flag.
|
read |
Returns true if data can be written to the file; otherwise false.
This is a convenience function which checks if the File.openMode of the file contains the File::WriteOnly flag.