Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface FileManager

FileManager (Drafts)

The ThoughtAsylum library includes a set of extensions to the FileManager object

Hierarchy

  • FileManager

Index

Methods

TA_delete

  • TA_delete(p_strFilePath: string): Boolean
  • Deletes a file. Returns true on a successful deletion.

    Parameters

    • p_strFilePath: string

      the path to the file in the Drafts area to be deleted.

      // Example
      let fmCloud = FileManager.createCloud();
      fmCloud.TA_delete("/Library/Scripts/old_file.txt");
      

    Returns Boolean

TA_fileMetaLoad

  • TA_fileMetaLoad(): string
  • Load the content for the current draft from the file path specified for it in the meta data file. For the current draft, the file path would be stored as draft.meta.filePath, and this is saved to a meta data file in iCloud, with the UUID of the draft being the key for its set of meta data. A valid path must be specified for the draft prior to running this function. It will replace all existing content in the draft. No warning is provided, but it will force a version save prior to loading. Returns true if the file saved successfully, and false if it did not.

    // Example
    let fmCloud = FileManager.createCloud();
    fmCloud.TA_fileMetaLoad();
    

    Returns string

TA_fileMetaPath

  • TA_fileMetaPath(): string
  • Set the file path for the current draft in the meta data file. For the current draft, the file path would be stored as draft.meta.filePath, and this is saved to a meta data file in iCloud, with the UUID of the draft being the key for its set of meta data. The user must manually enter the iCloud file path with the root (/) starting at the Drafts root folder. The path should also include the file extension. It will attempt to load the file path for the draft to allow for editing, but if no path is specified, it will simply default to the root folder and the file path should be added. Returns the specified file path.

    // Example
    let fmCloud = FileManager.createCloud();
    fmCloud.TA_fileMetaPath();
    

    Returns string

TA_fileMetaSave

  • TA_fileMetaSave(): Boolean
  • Save the current draft to the file path specified for it in the meta data file. For the current draft, the file path would be stored as draft.meta.filePath, and this is saved to a meta data file in iCloud, with the UUID of the draft being the key for its set of meta data. A valid path must be specified for the draft prior to running this function. Returns true if the file saved successfully, and false if it did not.

    // Example
    let fmCloud = FileManager.createCloud();
    fmCloud.TA_fileMetaSave();
    

    Returns Boolean

TA_listFilesRegex

  • TA_listFilesRegex(p_strPath: string, p_strRegEx: RegExp): string[]
  • List files in a directory matching a regular expression. The regular expression is matched against the file name, with the function returning an array of matching file paths. The file path to search is relative to the Drafts directory (local or cloud, as specified by the FileManager creation);

    Parameters

    • p_strPath: string

      the file path in the Drafts directory to be listed for matching files.

    • p_strRegEx: RegExp

      the regular expression (including forward slashes and modifiers) to be used in matching the file name.

      // Example
      let fmCloud = FileManager.createCloud();
      // Files with a ".txt" file extension
      alert(fmCloud.TA_listFilesRegex("/L", /\.txt$/).join("\n"));
      

    Returns string[]

TA_snapshot

  • TA_snapshot(p_strFilePath: string): Boolean
  • Snapshot a file by duplicating it in the same folder, but prefixing the file name with a time stamp. Returns true the successful creation of the file.

    Parameters

    • p_strFilePath: string

      the path to the file in the Drafts area to be snapshotted.

      // Example
      let fmCloud = FileManager.createCloud();
      fmCloud.TA_snapshot("/Library/some_file.txt");
      

    Returns Boolean