
39
3
File System Access
Adobe ExtendScript defines classes that simplify cross-platform file-system access. These classes are
available to all applications that support a JavaScript interface.
X The first part of this chapter, Using File and Folder objects, describes how to use these classes and
provides details of pathname syntax.
X “File object” on page 47 and “Folder object” on page 56 provide reference details of the objects,
properties, methods, and creation parameters. You can also choose the Core JavaScript Classes
dictionary from the Help menu in the ExtendScript Toolkit to inspect the objects in the Object Model
Viewer.
Using File and Folder objects
Because path name syntax is very different on Windows, Mac OS, and UNIX
®
, Adobe ExendScript defines
the
File and Folder objects to provide platform-independent access to the underlying file system. A
File object represents a disk file, a Folder object represents a directory or folder.
X The Folder object supports file system functionality such as traversing the hierarchy; creating,
renaming or removing files; or resolving file aliases.
X The File object supports input/output functions to read or write files.
There are several ways to distinguish between a
File and a Folder object. For example:
if (f instanceof File) ...
if (typeof f.open == "undefined") ...// Folders do not open
File
and Folder objects can be used anywhere that a path name is required, such as in properties and
arguments for files and folders.
N
OTE: When you create two File objects that refer to the same disk file, they are treated as distinct
objects. If you open one of them for I/O, the operating system may inhibit access from the other object,
because the disk file already is open.
Specifying paths
When creating a File or Folder object, you can specify a platform-specific path name, or an absolute or
relative path in a platform-independent format known as universal resource identifier (URI) notation. The
path stored in the object is always an absolute, full path name that points to a fixed location on the disk.
X Use the toString method to obtain the name of the file or folder as string containing an absolute
path name in URI notation.
X Use the fsName property to obtain the platform-specific file name.
Comentarios a estos manuales