org.autoplot.datasource.FileSystemUtil

More abstract filesystem functions.

FileSystemUtil( )


copyFile

copyFile( java.io.File partFile, java.io.File targetFile ) → boolean

copy the file to a new name.

Parameters

partFile - a File
targetFile - a File

Returns:

a boolean

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


deleteFilesInTree

deleteFilesInTree( java.io.File root, org.autoplot.datasource.FileSystemUtil.Check shouldDelete ) → boolean

deletes all files where shouldDelete returns true and empty folders below root, and root. If a directory is left empty, then it is also deleted.

Parameters

root - the root of the tree to start searching. If root does not exist, return true!
shouldDelete - an object which returns true if the file should be deleted, or if null is used, then any file is deleted.

Returns:

true if the operation was successful.

See Also:

org.das2.util.filesystem.FileSystemUtil#deleteAllFiles(java.io.File, java.lang.String)


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


doDownload

Deprecated: use DataSetURI.getFile instead

getNameRelativeTo

getNameRelativeTo( org.das2.util.filesystem.FileSystem fs, String resource ) → String

Parameters

fs - a FileSystem
resource - a String

Returns:

java.lang.String

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


getPresentWorkingDirectory

getPresentWorkingDirectory( ) → File

get the current working directory (pwd)

Returns:

the current working directory.

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


hasParent

hasParent( java.net.URL url ) → boolean

return true if the file has a parent which is resolvable.

Parameters

url - an URL

Returns:

 {@code
 from org.autoplot.datasource import FileSystemUtil
 print FileSystemUtil.hasParent(URL('http://autoplot.org/data/2016/ace_mag_2016_001.cdf'))  # True
 print FileSystemUtil.hasParent(URL('http://autoplot.org/Image:tabs.png'))  # False
 }
 


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


isChildOf

isChildOf( java.io.File possibleParent, java.io.File maybeChild ) → boolean

return true if the possibleParent is a valid folder tree root, and maybeChild exists within tree.

Parameters

possibleParent - parent file.
maybeChild - a file or folder which may exist within possibleParent.

Returns:

true if possibleParent is a folder containing

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


isLocalResource

isLocalResource( String file ) → boolean

return true if the resource is local, and can therefore be trusted. This was introduced to secure the server, where an Autoplot there could be used to access local resources. This returns true for file:/ references. Note this will also return true for sftp since the reference may utilize keys private to the server. Note too that a .jyds script that is not local could attempt to use local resources. For this reason there is JythonDataSourceFactory.hasLocalReferences. "upload" is another magic element. Paths containing "upload" are considered remote. This is to allow areas where content is uploaded.

Parameters

file - an Autoplot URI.

Returns:

true if the uri is a reference to a local resource.

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


resourceExists

resourceExists( String suri ) → boolean

checks to see if the resource uri appears to represent an existing data source. false indicates that the resource is known to not exist. true indicates that the resource does exist.

Parameters

suri - URI, such as http://server.org/data/asciitable.dat

Returns:

true of the resource exists and can be downloaded.

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


resourceIsLocal

resourceIsLocal( String suri ) → boolean

returns true if the resource is already in a local cache.

Parameters

suri - the URI containing a file resource.

Returns:

true if the resource is already in a local cache.

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