
CHAPTER 3: File System Access File object 52
execute()
fileObj.execute ()
Opens this file using the appropriate application, as if it had been double-clicked in a file browser.
You can use this method to run scripts, launch applications, and so on.
Returns true immediately if the application launch was successful.
getRelativeURI()
fileObj.getRelativeURI ([basePath])
basePath
Optional. A string containing the base path for the relative URI. Default is the current
folder.
Retrieves the URI for this file, relative to the specified base path, in URI notation. If no base path is
supplied, the URI is relative to the path of the current folder.
Returns a string containing the relative URI.
open()
fileObj.open (mode[,type][,creator])
mode
A string indicating the read/write mode. One of:
X r: (read) Opens for reading. If the file does not exist or cannot be found, the call
fails.
X w: (write) Opens a file for writing. If the file exists, its contents are destroyed. If
the file does not exist, creates a new, empty file.
X e: (edit) Opens an existing file for reading and writing.
X a: (append) Opens the file in Append mode, and moves the current position to
the end of the file.
type
Optional. In Mac OS, the type of a newly created file, a 4-character string. Ignored in
Windows and UNIX.
creator
Optional. In Mac OS, the creator of a newly created file, a 4-character string. Ignored
in Windows and UNIX.
Opens the referenced file for subsequent read/write operations. The method resolves any aliases to
find the file.
Returns true if the file has been opened successfully, false otherwise.
The method attempts to detect the encoding of the open file. It reads a few bytes at the current
location and tries to detect the Byte Order Mark character
0xFFFE. If found, the current position is
advanced behind the detected character and the encoding property is set to one of the strings
UCS-2BE, UCS-2LE, UCS4-BE, UCS-4LE, or UTF-8. If the marker character is not found, it checks for
zero bytes at the current location and makes an assumption about one of the above formats (except
UTF-8). If everything fails, the
encoding property is set to the system encoding.
N
OTE: Be careful about opening a file more than once. The operating system usually permits you to
do so, but if you start writing to the file using two different
File objects, you can destroy your data.
Kommentare zu diesen Handbüchern