commandbox.system.util

Class FileSystem

lucee.Component
    extended by commandbox.system.util.FileSystem

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I contain helpful methods for dealing with file and directory paths

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    any configService


    • access = public
    • returntype = any
    • inject = configService
    true false
    any coreClassLoader


    • access = public
    • returntype = any
    true false
    any logger


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any os
          The os.

    • access = public
    • returntype = any
    true false
    any shell


    • access = public
    • returntype = any
    • inject = shell
    true false
    any tempDir


    • access = public
    • returntype = any
    • inject = tempDir@constants
    true false
    Constructor Summary
    init()
    Method Summary
    any _classLoad([string path])
    array browserList()
    string calculateCanonicalPath(string path)
         I wrote my own version of this because the getCanonicalPath() runs isDirectory() and exists().
    any classLoad([any paths])
    any createMapping([any mappingName], [any mappingPath])
    any extractTarGz(string sourceFile, string targetFolder)
         Extract a tar.
    string getConfigService()
    any getCoreClassLoader([string path])
    any getDefaultNativeShell()
    any getJREExecutable([any javaHome])
         Get the JRE Executable from the File System.
    any getJavaFile(any file)
         Get a native java.
    string getLogger()
    any getNativeShell()
    string getOs()
    string getShell()
    string getTempDir()
    boolean isDriveRoot(string path)
         Tells you if a path is the drive root.
    boolean isLinux()
    boolean isMac()
    boolean isWindows()
    string locateDriveMapping(string driveLetter)
         Accepts a Windows drive letter and returns a CF Mapping.
    string locateUNCMapping(string UNCShare)
         Accepts a Windows UNC network share and returns a CF Mapping.
    string locateUnixDriveMapping(string rootFolder)
         Accepts a Unix root folder and returns a CF Mapping.
    any lockingFileRead(string path)
    any lockingFileWrite(string path, string contents)
    string makePathRelative(string absolutePath)
         Accepts an absolute path and returns a relative path.
    any normalizeSlashes([string path])
    boolean openBrowser(any URI, [any browser=''])
         Operating system browser opener.
    boolean openNatively(any file)
         Operating system open files or directories natively.
    any resolvePath(string path, [any basePath='[runtime expression]'], [boolean forceDirectory='false'])
         This resolves an absolute or relative path using the rules of the operating system and CLI.
    any setConfigService(any configService)
    any setCoreClassLoader(any coreClassLoader)
    any setLogger(any logger)
    any setOs(any os)
    any setShell(any shell)
    any setTempDir(any tempDir)
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()


    Property Detail

    configService

    property any configService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - configService
    serializable - true

    coreClassLoader

    property any coreClassLoader

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    logger

    property any logger

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    os

    property any os

    The os

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    shell

    property any shell

    Attributes:
    access - public
    required - false
    returntype - any
    inject - shell
    serializable - true

    tempDir

    property any tempDir

    Attributes:
    access - public
    required - false
    returntype - any
    inject - tempDir@constants
    serializable - true

    Method Detail

    _classLoad

    public any _classLoad([string path])

    Parameters:
    path

    browserList

    public array browserList()


    calculateCanonicalPath

    public string calculateCanonicalPath(string path)

    I wrote my own version of this because the getCanonicalPath() runs isDirectory() and exists() checks inside of it which SLOW DOWN when ran tens of thousands of times at once! This function differs from getCanonicalPath() in that it won't append a trailing slash if the path points to an actual folder.

    Parameters:
    path - The path to Canonicalize

    classLoad

    public any classLoad([any paths])

    Parameters:
    paths

    createMapping

    public any createMapping([any mappingName], [any mappingPath])

    Parameters:
    mappingName
    mappingPath

    extractTarGz

    public any extractTarGz(string sourceFile, string targetFolder)

    Extract a tar.gz file into a folder

    Parameters:
    sourceFile
    targetFolder

    getConfigService

    public string getConfigService()


    getCoreClassLoader

    public any getCoreClassLoader([string path])

    Parameters:
    path

    getDefaultNativeShell

    public any getDefaultNativeShell()


    getJREExecutable

    public any getJREExecutable([any javaHome])

    Get the JRE Executable from the File System

    Parameters:
    javaHome

    getJavaFile

    public any getJavaFile(any file)

    Get a native java.io.File object

    Parameters:
    file

    getLogger

    public string getLogger()


    getNativeShell

    public any getNativeShell()


    getOs

    public string getOs()


    getShell

    public string getShell()


    getTempDir

    public string getTempDir()


    isDriveRoot

    public boolean isDriveRoot(string path)

    Tells you if a path is the drive root

    Parameters:
    path - The path to look at

    isLinux

    public boolean isLinux()


    isMac

    public boolean isMac()


    isWindows

    public boolean isWindows()


    locateDriveMapping

    public string locateDriveMapping(string driveLetter)

    Accepts a Windows drive letter and returns a CF Mapping Creates the mapping if it doesn't exist

    Parameters:
    driveLetter

    locateUNCMapping

    public string locateUNCMapping(string UNCShare)

    Accepts a Windows UNC network share and returns a CF Mapping Creates the mapping if it doesn't exist

    Parameters:
    UNCShare

    locateUnixDriveMapping

    public string locateUnixDriveMapping(string rootFolder)

    Accepts a Unix root folder and returns a CF Mapping Creates the mapping if it doesn't exist

    Parameters:
    rootFolder

    lockingFileRead

    public any lockingFileRead(string path)

    Parameters:
    path

    lockingFileWrite

    public any lockingFileWrite(string path, string contents)

    Parameters:
    path
    contents

    makePathRelative

    public string makePathRelative(string absolutePath)

    Accepts an absolute path and returns a relative path Does NOT apply any canonicalization

    Parameters:
    absolutePath

    normalizeSlashes

    public any normalizeSlashes([string path])

    Parameters:
    path

    openBrowser

    public boolean openBrowser(any URI, [any browser=''])

    Operating system browser opener

    Parameters:
    URI - the URI to open
    browser - the browser to use

    openNatively

    public boolean openNatively(any file)

    Operating system open files or directories natively

    Parameters:
    file - the file/directory to open

    resolvePath

    public any resolvePath(string path, [any basePath='[runtime expression]'], [boolean forceDirectory='false'])

    This resolves an absolute or relative path using the rules of the operating system and CLI. It doesn't follow CF mappings and will also always return a trailing slash if pointing to an existing directory. Resolve the incoming path from the file system

    Parameters:
    path - The directory to resolve
    basePath - An expanded base path to resolve the path against. Defaults to CWD.
    forceDirectory - is for optimization. If you know the path is a directory for sure, pass true and we'll skip the directoryExists() check for performance

    setConfigService

    public any setConfigService(any configService)

    Parameters:
    configService

    setCoreClassLoader

    public any setCoreClassLoader(any coreClassLoader)

    Parameters:
    coreClassLoader

    setLogger

    public any setLogger(any logger)

    Parameters:
    logger

    setOs

    public any setOs(any os)

    Parameters:
    os

    setShell

    public any setShell(any shell)

    Parameters:
    shell

    setTempDir

    public any setTempDir(any tempDir)

    Parameters:
    tempDir