Working With Folders; Creating Folders; Retrieving The Contents Of A Folder; Getting Files From A File Object - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide

Working With Folders

When the files you are working with are not part of a GoLive site, you can use file objects to create and
manipulate folders. If the files are part of a web site, the webSite object offers higher-level options; see
Chapter 10, "Managing Web

Creating folders

To create a folder, you must first create or acquire a file object that holds the path to the new folder. After
validating the file object, call its createFolder method to create the folder at this location. For
example, the following code fragment creates a new file object for an existing location, then uses it to
create the myFolder folder:
var myFoldObj = new JSXFile("C:\myRoot\myFolder\");
if (!myFoldObj.isFolder) // no destination folder, so create it.
{
if (!(myFoldObj.createFolder())) // folder creation failed
{
Window.alert("Could not create folder.");
}
}
There are a number of reasons an attempt to create a folder might fail:
If the folder already exists, the createFolder method exits without overwriting it.
The method fails if the pathname used to initialize the called file object is incorrect.
The method fails if an error is returned by the host file system—for instance, if there is not adequate
disk space or memory to create the folder.
The JSXFile constructor fails when passed invalid characters.

Retrieving the contents of a folder

To acquire file objects for the files and folders in a specified folder, use the getFiles method of that
folder's
file Object
These functions retrieve only the immediate contents of the folder. To get the contents of a subfolder
inside this object's folder, you must call that subfolder object's getFiles method.

Getting files from a file object

For a
file
or folder that matches the search criteria.
var aFileObj = new JSXFile(
var returnedItems = aFileObj.getFiles([
If this object does not represent an existing folder (if it is a file, for example), the getFiles method
returns null .
The optional arguments specify search criteria that a disk entity must meet to be included in the result.
If you pass no arguments, the method returns all files and folders in this object's folder.
Sites.
or
siteReference
Object, the getFiles method returns an Array object, which contains a file object for each file
Adobe GoLive CS2 SDK
Object. The method is similar in the two objects, but not identical.
path
);
mask
Managing Files and Folders
type
,
]);
130

Advertisement

Table of Contents
loading

Table of Contents