myFile.open( mode, [ type ], [ creator ] ) in Photoshop DOM
Open the file for read/write operations.
Arguments
name | type | description |
---|---|---|
mode | String |
One of 'r' ,
|
type | String | [optional] Four character MacOS file type |
creator | String | [optional] Four character MacOS creator t |
- Return Type
- Boolean
Description
Open the file for subsequent read/write operations. The type
and creator
optional arguments are Macintosh specific; they specify the file type and creator as two four-character strings. They are used if the file is newly created. On other platforms, they are ignored.
The mode
parameter's values mean the following:
'r'
- read — Opens for reading. If the file does not exist or cannot be found the call fails.
'w'
- write — Opens an empty file for writing. If the file exists, its contents are destroyed.
'e'
- edit — Open an existing file for reading and writing.
When used to open a file for read access, 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 cannot be found, it checks for zero bytes at the current location and makes an assumption about one of the above formats (except for UTF-8). If everything fails, the encoding property is set to the system encoding. The method resolves any aliases to find the file.
If you try to open a file for writing or editing 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 may destroy your data!
The return value is true
if the file has been opened successfully, false
otherwise.