## org.das2.util.filesystem.FileSystem

Filesystems provide an abstraction layer so that clients can access any hierarchy of files in a implementation-independent way. For example, remote filesystems accessible via HTTP are accessible through the same interface as a local filesystem.

## PROP_CASE_INSENSITIVE

Boolean.TRUE if the filesystem ignores case, such as Windows local filesystem.

## NULL

result from failed listing, etc.

## create

Deprecated: use create( URI root ) instead.

## create

create( String s ) → org.das2.util.filesystem.FileSystem

convenient method that converts string like "http://das2.org/" into a URI.

### Parameters

s - string representation of URI, like "http://das2.org/" or "file:///tmp/"

### Returns:

FileSystem object.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## create

create( String s, ProgressMonitor mon ) → org.das2.util.filesystem.FileSystem

convenient method that converts string like "http://das2.org/" into a URI. See http://stackoverflow.com/questions/573184/java-convert-string-to-valid-uri-object , about halfway down for Feb 21 '09 answer.

### Parameters

s - string representation of URI, like "http://das2.org/" or "file:///tmp/"
mon - monitor progress. For most FS types this is instantaneous, but for zip this can take sub-interactive time.

### Returns:

FileSystem object.
[search for examples] [view on GitHub] [view on old javadoc] [view source]
create( java.net.URL root, ProgressMonitor mon ) → org.das2.util.filesystem.FileSystem [view source]

## create

create( java.net.URI root ) → org.das2.util.filesystem.FileSystem

Creates a FileSystem by parsing the URI and creating the correct FS type. Presently, file, http, and ftp are supported. If the URI contains a folder ending in .zip and a FileSystemFactory is registered as handling .zip, then The zip file will be transferred and the zip file mounted.

### Parameters

root - an URI

### Returns:

an org.das2.util.filesystem.FileSystem
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## create

create( java.net.URI root, ProgressMonitor mon ) → org.das2.util.filesystem.FileSystem

Creates a FileSystem by parsing the URI and creating the correct FS type. Presently, file, http, and ftp are supported. If the URI contains a folder ending in .zip and a FileSystemFactory is registered as handling .zip, then The zip file will be transferred and the zip file mounted. Note "user" is a special placeholder in http://user@das2.org.

### Parameters

root - the URI, like URI("http://das2.org/") or URI("file:///tmp/")
mon - monitor progress. For most FS types this is instantaneous, but for zip this can take sub-interactive time.

### Returns:

the FileSystem implementation
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## createFileSystem

createFileSystem( String directory ) → org.das2.util.filesystem.FileSystem

create a new filesystem that is a part of this filesystem, rooted at directory.

### Parameters

directory - subdirectory within the filesystem.

### Returns:

the new FileSystem
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getExceptionHandler

getExceptionHandler( ) → org.das2.util.ExceptionHandler

return the exception handler.

### Returns:

the exception handler.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getFileObject

getFileObject( String filename ) → org.das2.util.filesystem.FileObject

return the FileObject that corresponds to the name.

### Parameters

filename - the file name within the filesystem

### Returns:

the FileObject
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getListing

getListing( org.das2.util.filesystem.FileSystem.DirectoryEntry[] des ) → String[]

part of the refactoring to cache time stamps as well, this convenience method returns the old string. This returns des.name, plus '/' if it's a directory.

### Parameters

des - array of directory entries.

### Returns:

des.name, and
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getListing

getListing( java.util.Map des ) → String[]

part of the refactoring to cache time stamps as well, this convenience method returns the old string. This returns des.name, plus '/' if it's a directory.

### Parameters

des - Map of directory entries.

### Returns:

des.name, and
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getLocalRoot

getLocalRoot( ) → java.io.File

return the folder that is a local copy of the filesystem. For LocalFilesystem, this is the same as the filesystem. For remote filesystems, this is a folder within their home directory. Note File.getAbsolutePath() returns the string representation of this root.

### Returns:

the folder that is a local copy of the filesystem.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getProperty

getProperty( String name ) → Object

return a filesystem property, such as PROP_CASE_INSENSITIVE.

### Parameters

name - property name, e.g. PROP_CASE_INSENSITIVE

### Returns:

the property value, e.g. Boolean.TRUE
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getRootURI

getRootURI( ) → java.net.URI

return the URI identifying the root of the filesystem.

### Returns:

a java.net.URI
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isDirectory

isDirectory( String filename ) → boolean

return true if the name is a directory.

### Parameters

filename - the name

### Returns:

true if the name is a directory.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## listDirectory

listDirectory( String directory ) → String[]

returns a list of the names of the files in a directory. Names ending in "/" are themselves directories, and the "/" is not part of the name. This is optional, and a directory may or may not be tagged with the trailing slash.

### Parameters

directory - the directory name within the filesystem.

### Returns:

list of files and folders within the filesystem.

### See Also:

listDirectory(java.lang.String, java.lang.String) for listings constrained by regular expressions.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## listDirectory

listDirectory( String directory, ProgressMonitor monitor ) → String[]

returns a list of the names of the files in a directory. Names ending in "/" are themselves directories, and the "/" is not part of the name.

### Parameters

directory - the directory name within the filesystem.
monitor - a progress monitor for the task.

### Returns:

list of files and folders within the filesystem.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## listDirectory

listDirectory( String directory, String regex ) → String[]

returns a list of the names of the files in a directory that match regex. Trailing slashes on directory names are not part of the name and need not be part of the regex. Note regex is a regular expression (.*\.dat), not a glob (*.dat)

### Parameters

directory - the directory
regex - regular expression

### Returns:

a String[]
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## listDirectory

listDirectory( String directory, String regex, ProgressMonitor monitor ) → String[]

returns a list of the names of the files in a directory that match regex. Trailing slashes on directory names are not part of the name and need not be part of the regex. Note regex is a regular expression (.*\.dat), not a glob (*.dat)

### Parameters

directory - a String
regex - regular expression that must be matched, or null.
monitor - progress monitor for the task.

### Returns:

names of files within the directory which match the regex.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## listDirectoryDeep

listDirectoryDeep( String directory, String regex ) → String[]

do a deep listing of directories, resolving wildcards along the way. Note this can be quite expensive, so be careful when levels are too deep.

### Parameters

directory - location within the filesystem.
regex - regular expression (.*\.dat) (not a glob like *.dat).

### Returns:

the entire path of each matching name, including the directory within the filesystem.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## peek

peek( java.net.URI root ) → org.das2.util.filesystem.FileSystem

allow factories to peek, so they can see if there is a parent that is offline.

### Parameters

root - the URI

### Returns:

null if not existing, or the filesystem for the URI.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## peekInstances

peekInstances( ) → org.das2.util.filesystem.FileSystem[]

return a copy of all cached filesystems

### Returns:

an org.das2.util.filesystem.FileSystem[]
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## recreate

recreate( java.net.URI root ) → org.das2.util.filesystem.FileSystem

creates a FileSystem, removing and recreating it if it was in the cache.

### Parameters

root - an URI

### Returns:

an org.das2.util.filesystem.FileSystem
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## recreate

recreate( java.net.URI root, ProgressMonitor mon ) → org.das2.util.filesystem.FileSystem

creates a FileSystem, removing and recreating it if it was in the cache.

### Parameters

root - an URI
mon - a ProgressMonitor

### Returns:

an org.das2.util.filesystem.FileSystem
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## registerFileSystemFactory

registerFileSystemFactory( String proto, org.das2.util.filesystem.FileSystemFactory factory ) → void

register a code for handling a filesystem type. For example, an FTP implementation can be registered to handle URIs like "ftp://autoplot.org/"

### Parameters

proto - protocol identifier, like "ftp" "http" or "sftp"
factory - the factory which will handle the URI.

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## reset

reset( ) → void

remove all the cached FileSystem instances.

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## reset

reset( org.das2.util.filesystem.FileSystem fs ) → void

remove all the cached FileSystem instances.

### Parameters

fs - the filesystem

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## setExceptionHandler

setExceptionHandler( org.das2.util.ExceptionHandler eh ) → void

set the exception handler that is called when exceptions occur.

### Parameters

eh - the exception handler.

### Returns:

void (returns nothing)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## settings

settings( ) → org.das2.util.filesystem.FileSystemSettings

access the file system settings.

### Returns:

the single settings object.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## splitUrl

splitUrl( String surl ) → String[]

returns a String[5]:``

       [0] is proto "http://"
       [1] will be the host
       [2] is proto + path
       [3] is proto + path + file
       [4] is file ext
       [5] is params, not including ?.

The URL must start with one of file:, ftp://, http://, https://, sftp:// and "c:" is interpreted as "file:///c:..."

### Parameters

surl - a URL string to parse.

### Returns:

the parsed URL.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## toCanonicalFilename

toCanonicalFilename( String filename ) → String

returns the canonical name /a/b/c.dat of a string that may contain backslashes and might not have the leading / and trailing slashes. Also, double slashes (//) are removed. Even for Windows files, forward slashes are used.

### Parameters

filename - name

### Returns:

name with \ converted to /, etc.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## toCanonicalFolderName

toCanonicalFolderName( String name ) → String

returns the canonical name (/a/b/) of a string that may contain backslashes and might not have the leading / and trailing slashes. Also, double slashes (//) are removed. Note this is the name of the FileObject within the FileSystem.

### Parameters

name - folder name

### Returns:

name with \ converted to /, etc.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## toCanonicalFolderNameString

toCanonicalFolderNameString( java.net.URI name ) → String

return the canonical name for the folder located with URI

### Parameters

name - an URI

### Returns:

a String
[search for examples] [view on GitHub] [view on old javadoc] [view source]