13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with the file system<br />

var desktopNodes:Array = File.desktopDirectory.getDirectoryListing();<br />

for (var i:uint = 0; i < desktopNodes.l<strong>en</strong>gth; i++)<br />

{<br />

if (!desktopNodes[i].isSymbolicLink)<br />

{<br />

trace(desktopNodes[i].name);<br />

}<br />

}<br />

The canonicalize() method changes the path of a symbolic link to point to the file or directory to which the link<br />

refers. The following code iterates through the user’s desktop directory, and reports the paths refer<strong>en</strong>ced by files that<br />

are symbolic links:<br />

var desktopNodes:Array = File.desktopDirectory.getDirectoryListing();<br />

for (var i:uint = 0; i < desktopNodes.l<strong>en</strong>gth; i++)<br />

{<br />

if (desktopNodes[i].isSymbolicLink)<br />

{<br />

var linkNode:File = desktopNodes[i] as File;<br />

linkNode.canonicalize();<br />

trace(linkNode.nativePath);<br />

}<br />

}<br />

Determining space available on a volume<br />

Adobe AIR 1.0 and later<br />

The spaceAvailable property of a File object is the space available for use at the File location, in bytes. For example,<br />

the following code checks the space available in the application storage directory:<br />

trace(File.applicationStorageDirectory.spaceAvailable);<br />

If the File object refer<strong>en</strong>ces a directory, the spaceAvailable property indicates the space in the directory that files can<br />

use. If the File object refer<strong>en</strong>ces a file, the spaceAvailable property indicates the space into which the file could grow.<br />

If the file location does not exist, the spaceAvailable property is set to 0. If the File object refer<strong>en</strong>ces a symbolic link,<br />

the spaceAvailable property is set to space available at the location the symbolic link points to.<br />

Typically the space available for a directory or file is the same as the space available on the volume containing the<br />

directory or file. However, space available can take into account quotas and per-directory limits.<br />

Adding a file or directory to a volume g<strong>en</strong>erally requires more space than the actual size of the file or the size of the<br />

cont<strong>en</strong>ts of the directory. For example, the operating system may require more space to store index information. Or<br />

the disk sectors required may use additional space. Also, available space changes dynamically. So, you cannot expect<br />

to allocate all of the reported space for file storage. For information on writing to the file system, see “Reading and<br />

writing files” on page 687.<br />

The StorageVolumeInfo.getStorageVolumes() method provides more detailed information on mounted storage<br />

volumes (see “Working with storage volumes” on page 686).<br />

Last updated 6/6/2012<br />

679

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!