Acquiring File Objects; Determining The Location Of A File Or Folder; Validating File Objects - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
disk-based entity it represents; the object simply holds the pathname to one file or folder. Its methods
operate on that file or folder if it is available at the specified location. The file object issues requests to a
local or remote file system that actually does the work. If this file system fails to complete its task, the
request fails. You can check whether the disk entity exists before calling the methods that operate on it;
see
Validating file
The file object functions that read, write, or create files do not necessarily create document objects. To
display changes to a disk file's content on the screen in Layout view, you must call the reparse method of
the associated document object. Similarly, when you use file objects to change a site's structure by
adding, deleting, moving, or copying files, you must call the site document's reparse method to update
the Site window display.

Acquiring file objects

Properties of the
used folders, such as the one that holds the GoLive application. See
Global functions that display file browsers, such as the filePutDialog and folderGetDialog ,
returns a file object for the user's selection in the dialog. When the user cancels, these functions
return null. See
You can create your own file objects explicitly using the constructor. See

Determining the location of a file or folder

A file object's parent property contains another file object for the referenced file or folder's parent
folder. The value of this property is null for a file that resides in the root folder of the file system.

Validating file objects

A newly constructed file object holds the full pathname of the file or folder it represents. This file or
folder does not necessarily exist. You can, in fact, use the new file object to create the file or folder on
disk. Further, the disk entity a can change at any time.
Before working with a file object, you need to know whether it represents a file or folder and whether
that file or folder actually exists on disk at the specified location:
To test whether a file or folder actually exists at the specified location, check the exists property.
To test whether the disk entity is a file or a folder, check the isFile and isFolder properties.
This example creates a new file object for a file named myFile.html . It ensures that the
myFile.html file exists in the C:\myRoot\ folder, and that it is not actually a folder (whose name
happens to look like a filename), before using the object's copy method to copy the file to the location
specified by the destinationURL path:
var myPic = new JSXFile("C:\myRoot\myFile.html");
if (myPic.exists && !myPicture.isFolder)
{
myPic.copy(
}
The value of isFolder is true when the object's path matches a folder that exists on disk at the specified
location. When the value is false , there is no folder at the object's named location. The folder may have
Adobe GoLive CS2 SDK
objects.
app Object
and
document Object
Getting a file object from the
destinationURL
);
provide file objects that represent commonly
Accessing
user.
Managing Files and Folders
folders.
Creating a new file object
124

Advertisement

Table of Contents
loading

Table of Contents