Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WAKFolderInstance

Hierarchy

  • WAKFolderInstance

Index

Properties

creationDate

creationDate: Date

Creation date for the folder.

exists

exists: Boolean

true if the folder exists at the defined path, false otherwise.

extension

extension: String

Folder extension.

files

files: Array<WAKFileInstance>

Array of Files.

firstFile

firstFile: WAKFileInstance

First file found in the folder.

firstFolder

firstFolder: WAKFolderInstance

First folder (i.e., subfolder) in the folder.

folders

folders: Array<WAKFolderInstance>

Array of Folder objects.

modificationDate

modificationDate: Date

Last modification date for the folder.

name

name: String

Name of the folder without the path.

nameNoExt

nameNoExt: String

Name of the folder without the extension.

parent

Parent folder of the folder.

path

path: String

Full path of the folder.

visible

visible: Boolean

true if the folder is visible, false otherwise.

Methods

create

  • create(): Boolean
  • Creates a new folder on disk.

    var myFolder = new Folder( 'PROJECT/my-created-folder' );
    var myResult = myFolder.create();
    console.log( myResult );
    // true
    throws

    An error if something goes wrong: folder already exists, invalid path, ...

    Returns Boolean

    true if the folder is well created

forEachFile

  • forEachFile(callback: function, thisArg?: Object): void
  • Calls callback function for each file at the first level of the folder.

    Example 1: Basic usage

    var folder = new Folder( 'PROJECT/' );
    folder.forEachFile( function( file )
    {
        console.log( file.path );
    });

    Example 2: Override this

    var folder = new Folder( 'PROJECT/' );
    folder.forEachFile( function( file )
    {
        console.log( this );
    }, {data: 'some-data' } );
    // {"data":"some-data"}
    warning

    break is not working in forEachFile

    Parameters

    • callback: function

      Defines the function called for each file

    • Optional thisArg: Object

      Defines this value of the callback

    Returns void

forEachFolder

  • forEachFolder(callback: function, thisArg?: Object): void
  • Calls callback function for each folder at the first level of the folder.

    Example 1: Basic usage

    var folder = new Folder( 'PROJECT/' );
    folder.forEachFolder( function( folder )
    {
        console.log( folder.path );
    });

    Example 2: Override this

    var folder = new Folder( 'PROJECT/' );
    folder.forEachFolder( function( folder )
    {
        console.log( this );
    }, {data: 'some-data' } );
    // {"data":"some-data"}
    warning

    break is not working in forEachFolder

    Parameters

    • callback: function

      Defines the function called for each folder

    • Optional thisArg: Object

      Defines this value of the callback

    Returns void

getFreeSpace

  • getFreeSpace(quotas?: Boolean): Number
  • Returns the size of the free space (expressed in bytes) available on the volume where the Folder object is stored.

    Parameters

    • Optional quotas: Boolean

      (default: true) true if consider the whole volume, false if consider only the allowed size for the quota

    Returns Number

getURL

  • getURL(encoding?: Boolean): String
  • Returns the absolute URL of the Folder object.

    Parameters

    • Optional encoding: Boolean

      (default: false) true if encode the url, false otherwise.

    Returns String

getVolumeSize

  • getVolumeSize(): Number
  • Returns the total size (expressed in bytes) of the volume where the Folder object is stored.

    Returns Number

parse

  • parse(callback: function, thisArg?: Object): void
  • Calls callback function for each file in the folder tree (first-level and sub-level folder).

    Example 1: Basic usage

    var folder = new Folder( 'PROJECT/' );
    folder.parse( function( file, position, folder )
    {
        console.log( '-----------------------------' );
        console.log( file.path );
        console.log( position );
        console.log( folder.path );
    });

    Example 2: Override this

    var folder = new Folder( 'PROJECT/' );
    folder.parse( function( file, position, folder )
    {
        console.log( this );
    }, {data: 'some-data' } );
    // {"data":"some-data"}
    warning

    break is not working in parse

    Parameters

    • callback: function

      Defines the function called for each folder

    • Optional thisArg: Object

      Defines this value of the callback

    Returns void

remove

  • remove(): Boolean
  • Removes the folder and its content from the disk.

    Returns Boolean

    true if the folder is not here, false otherwise.

removeContent

  • removeContent(): Boolean
  • Removes the contents of the folder from the disk.

    Returns Boolean

setName

  • setName(newName: String): void
  • Rename the folder on disk.

    var myFolder = new Folder( 'PROJECT/my-folder' );
    // The folder must exists to be renamed
    myFolder.create();
    // The destination folder name must be free
    myFolder.setName( 'my-renamed-folder' );
    // myFolder always references the "my-folder" folder
    // The referenced folder did not change with the setName() action.
    console.log( myFolder.path );
    // PROJECT/my-folder
    warning

    The folder must exist on disk to be renamed

    warning

    The folder destination must be free

    throws

    An error if something goes wrong: folder already exists, invalid name, ...

    Parameters

    • newName: String

    Returns void

    true if the folder is successfully renamed