Class: oFolder

$. oFolder

$.oFolder Base Class

new $.oFolder(path)

openHarmony/openHarmony_file.js, line 60
The $.oFolder helper class -- providing utilities for folder manipulation and access.
Name Type Description
path string The path to the folder.
Properties:
Name Type Description
path string The path to the folder.

Members

contentArray.<$.oFile/$.oFolder>

The content within the folder -- both folders and files.

ContentTypeQFlag

Enum for the type of content to retrieve from the oFolder.
Properties:
Name Type Default Description
FOLDER QFlag
FILE QFlag QDir.Files

existsstring

The parent folder.

filesArray.<$.oFile>

The files in the folder.
Deprecated
  • use oFolder.getFiles() instead to specify filter

    folder$.oFolder

    The parent folder.

    foldersArray.<$.oFile>

    The folders within this folder.
    Deprecated
    • oFolder.folder is the containing parent folder, it can't also mean the children folders

      namestring

      The name of the folder.

      pathstring

      The path of the folder. Setting a path doesn't move the file, only changes where the file object is pointing.

      Methods

      copy(folderPath, copyName, overwrite){$.oFolder}

      openHarmony/openHarmony_file.js, line 344
      Copy the folder and its contents to another path.
      Name Type Default Description
      folderPath string The path to an existing folder in which to copy this folder. (Can provide an oFolder)
      copyName string optional Optionally, a name for the folder copy, if different from the original
      overwrite bool false optional Whether to overwrite the files that are already present at the copy location.
      Returns:
      Type Description
      $.oFolder the oFolder describing the newly created copy.

      create(){bool}

      openHarmony/openHarmony_file.js, line 324
      Creates the folder, if it doesn't already exist.
      Returns:
      Type Description
      bool The existence of the newly created folder.

      get(name)

      openHarmony/openHarmony_file.js, line 458
      Get the sub folder or file by name.
      Name Type Description
      name string The sub name of a folder or file within a directory.

      getFiles(filter){Array.<$.oFile>}

      openHarmony/openHarmony_file.js, line 282
      get the files from the folder
      Name Type Default Description
      filter string | Array.<string> "*" optional Wildcard (globbing) filter that understands * and ? wildcards. Used to filter the contents of the folder.
      Returns:
      Type Description
      Array.<$.oFile> A list of files contained in the folder that match the namefilter(s), as oFile objects.

      getFolders(filter){Array.<$.oFolder>}

      openHarmony/openHarmony_file.js, line 309
      gets the folders inside the oFolder
      Name Type Default Description
      filter string | Array.<string> "*" optional Wildcard (globbing) filter that understands * and ? wildcards. Used to filter the contents of the folder.
      Returns:
      Type Description
      Array.<$.oFolder> A list of folders contained in the folder that match the namefilter(s), as oFolder objects.

      listEntries(contentType, filter){Array.<string>}

      openHarmony/openHarmony_file.js, line 237
      Lists the contents of the folder, filtered by the contentType and name filter(s). Primarily a helper function for listFile/listFolder, but can be called directly to provide custom filtering by providing QDir::Filters to the contentType parameter.
      Name Type Default Description
      contentType $.oFolder.ContentType optional Type of content to retrieve.
      filter string | Array.<string> "*" optional Single filter, or array of filters for the contents of the folder.
      Returns:
      Type Description
      Array.<string> Names of the folder contents that match the filter and type provided.
      Examples
      // List files with a case-sensitive filter. Will match l* and not L*
      var dir = new $.oFolder("/tmp/example");
      dir.listEntries(QDir.Filters(QDir.Files | QDir.CaseSensitive), "l*")
      // List files including hidden files.
      var dir = new $.oFolder("/tmp/example");
      dir.listEntries(QDir.Filters(QDir.Files | QDir.Hidden))

      listFiles(filter){Array.<string>}

      openHarmony/openHarmony_file.js, line 271
      lists the file names contained inside the folder.
      Name Type Default Description
      filter string | Array.<string> "*" optional Wildcard (globbing) filter that understands * and ? wildcards. Used to filter the contents of the folder.
      Returns:
      Type Description
      Array.<string> Names of the files contained in the folder that match the namefilter(s).

      listFolders(filter){Array.<string>}

      openHarmony/openHarmony_file.js, line 298
      lists the folder names contained inside the folder.
      Name Type Default Description
      filter string | Array.<string> "*" optional Wildcard (globbing) filter that understands * and ? wildcards. Used to filter the contents of the folder.
      Returns:
      Type Description
      Array.<string> Names of the files contained in the folder that match the namefilter(s).

      move(destFolderPath, overwrite){bool}

      openHarmony/openHarmony_file.js, line 385
      Move this folder to the specified path.
      Name Type Default Description
      destFolderPath string The new complete path of the folder after the move
      overwrite bool false optional Whether to overwrite the target.
      TODO
      • implement with Robocopy
      Returns:
      Type Description
      bool The result of the move.

      moveToFolder(destFolderPath, overwrite)

      openHarmony/openHarmony_file.js, line 418
      Move this folder to a different parent folder, while retaining its content and base name.
      Name Type Default Description
      destFolderPath string The path of the destination to copy the folder into.
      overwrite bool false optional Whether to overwrite the target. Default is false.

      remove(removeContents)

      openHarmony/openHarmony_file.js, line 444
      Deletes the folder.
      Name Type Description
      removeContents bool Whether to check if the folder contains files before deleting.

      rename(newName)

      openHarmony/openHarmony_file.js, line 432
      Renames the folder
      Name Type Description
      newName string

      toString(){string}

      openHarmony/openHarmony_file.js, line 478
      Used in converting the folder to a string value, provides the string-path.
      Returns:
      Type Description
      string The folder path's as a string.