18
EXTENDING FIREWORKS
The Fireworks Object Model
Las
t
up
d
a
ted
12/8/2009
File Reference object
The File Reference object is used to refer to a specific open file. The following table lists the methods of the File
Reference object, along with their data types and, where appropriate, acceptable values and notes.
getTempFilePath ({dirname})
string
The argument, if used, must be expressed as
file://URL
. Returns
a file URL in the Temporary Files directory or in the specified
directory. This method does not create a file; it simply returns a
unique file URL that does not conflict with existing files in the
directory. If
dirname
is passed and is not
null
, the URL that is
returned indicates a file in the specified directory rather than in
the Temporary Files directory.
isDirectory(dirname)
string
The argument must be expressed as
file://URL
. Returns
true
if
the specified URL refers to a directory that exists;
false
otherwise.
makePathFromDirAndFile(dirna
me, plainFilename)
string, string
The first argument must be expressed as
file://URL
.
Concatenates the two arguments to return a file URL that
references the specified filename in the specified directory. For
example,
Files.makePathFromDirAndFile("file:///work/rep
orts", "logo.png")
returns
"file:///work/reports/logo.png".
open(docname, encoding,
bWrite)
string, string, Boolean
The first argument must be expressed as
file://URL
. Opens the
specified file for reading or writing. The second argument
specifies the encoding. If the third argument is
true
, the file
opens for writing; otherwise it opens for reading. If the file
cannot be opened, returns
null
; otherwise, returns a File
Reference object.
rename(docname,
newPlainFilename)
string, string
The
docname
argument is a file path or a file URL to the file that
you want to rename.
The
newPlainFilename
argument is the new name to assign
to the file.
The
rename
method returns a URL path of the newly renamed
file if successful; otherwise Fireworks returns
null
.
setFilename(docname,
newPlainFilename)
string, string
The first argument must be expressed as
file://URL
. Returns a
file URL with
docname
replaced by
newPlainFilename
. For
example,
Files.setFilename("file:///work/logo.png",
"oldlogo.png")
returns
"file:///work/oldlogo.png"
. This method does not
affect the file on disk; it simply provides a convenient way to
manipulate file URLs. To change the name on disk, use
rename()
.
swap(docname1, docname2)
string, string
Each argument must be expressed as a file://URL. Swaps the
contents of the two specified files, so that each file contains the
contents of the other file. Only files (not directories) can be
swapped, and both files must reside on the same drive. Returns
true
if the swap is successful;
false
otherwise.
Method
Data type
Notes