Namespace: VFS

VFS

Classes

File
FileDataURL

Namespaces

Helpers
Modules
Transports

Methods

staticOSjs.VFS.copy(src, dest, callback, options, appRef)

Copies a file to a destination

Copy File
Parameters:
Name Type Attributes Description
src OSjs.VFS.File Source File Metadata (you can also provide a string)
dest OSjs.VFS.File Destination File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Description
overwrite Boolean <optional>
If set to true it will not check if the destination exists
appRef OSjs.Core.Application <optional>
Seference to an Application

staticOSjs.VFS.delete()

Alias of unlink

staticOSjs.VFS.download(args, callback)

Downloads a file to the computer

Download a file
Parameters:
Name Type Description
args OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function

staticOSjs.VFS.emptyTrash(callback)

Empties the trash

Permanently empty trash
Parameters:
Name Type Description
callback CallbackVFS Callback function

staticOSjs.VFS.exists(item, callback)

Check if a target exists

Check if file exists
Parameters:
Name Type Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function

staticOSjs.VFS.file()

Creates a new VFS.File instance
See:
Example
OSjs.VFS.file('home:///foo').read(<fn>);

staticOSjs.VFS.fileinfo(item, callback)

Gets information about a file

Get file info
Parameters:
Name Type Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function

staticOSjs.VFS.find(item, args, callback, options)

Find file(s)
Parameters:
Name Type Attributes Description
item OSjs.VFS.File Root path
args Object Search query
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Description
query String The search query string
limit Number <optional>
Limit results to this amount

staticOSjs.VFS.freeSpace(item, callback)

Gets free space on target

Checks for free space in given protocol from file Result is -1 when unavailable
Parameters:
Name Type Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function

staticOSjs.VFS.mkdir(item, callback, options, appRef)

Creates a directory

Create Directory
Parameters:
Name Type Attributes Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Description
overwrite Boolean <optional>
If set to true it will not check if the destination exists
appRef OSjs.Core.Application <optional>
Reference to an Application

staticOSjs.VFS.move(src, dest, callback, options, appRef)

Moves a file to a destination

Move File
Parameters:
Name Type Attributes Description
src OSjs.VFS.File Source File Metadata (you can also provide a string)
dest OSjs.VFS.File Destination File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Description
overwrite Boolean <optional>
If set to true it will not check if the destination exists
appRef OSjs.Core.Application <optional>
Seference to an Application

staticOSjs.VFS.read(item, callback, options)

Reads data from a file

Read File
Parameters:
Name Type Attributes Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Description
type String <optional>
What to return, default: binary. Can also be: text, datasource, json

staticOSjs.VFS.rename(src, dest, callback, options, appRef)

Alias of move
Parameters:
Name Type Attributes Description
src OSjs.VFS.File Source File Metadata (you can also provide a string)
dest OSjs.VFS.File Destination File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Description
overwrite Boolean <optional>
If set to true it will not check if the destination exists
appRef OSjs.Core.Application <optional>
Seference to an Application

staticOSjs.VFS.scandir(item, callback, options)

Scans a directory for files and directories.

Scandir
Parameters:
Name Type Attributes Description
item OSjs.VFS.File File Metadata
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Default Description
typeFilter String <optional>
Filter by 'file' or 'dir'
mimeFilter Array <optional>
Array of mime regex matchers
showHiddenFiles Boolean <optional>
true Show hidden files
backlink Boolean <optional>
true Return '..' when applicable
sortBy String <optional>
null Sort by this key
sortDir String <optional>
'asc' Sort in this direction

staticOSjs.VFS.trash(item, callback)

Trashes a file

Move file to trash (Not used in internal storage)
Parameters:
Name Type Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function

Deletes a file

Delete File This function currently have no options.
Parameters:
Name Type Attributes Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options
appRef OSjs.Core.Application <optional>
Reference to an Application

staticOSjs.VFS.untrash(item, callback)

Removes a file from trash

Restore file from trash
Parameters:
Name Type Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function

staticOSjs.VFS.unwatch(idx)

Remove a watch
Parameters:
Name Type Description
idx Number Watch index (from watch() method)

staticOSjs.VFS.upload(args, callback, options, appRef)

Uploads a file to the target from browser

Upload file(s)
Parameters:
Name Type Attributes Description
args Object Function arguments (see below)
Properties
Name Type Description
destination String Full path to destination
files Array Array of 'File'
callback CallbackVFS Callback function
options Object <optional>
Set of options
Properties
Name Type Attributes Default Description
overwrite Boolean <optional>
false If set to true it will not check if the destination exists
appRef OSjs.Core.Application <optional>
Reference to an Application

staticOSjs.VFS.url(item, callback, options)

Gets absolute HTTP URL to a file

Get file URL
Parameters:
Name Type Attributes Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function
options Object <optional>
Set of options

staticOSjs.VFS.watch(item, callback){Number}

Watches a file or directory for changes.

Watches a file or directory for changes. Please note that this currently only works for client-side APIs.
Parameters:
Name Type Description
item OSjs.VFS.File File Metadata (you can also provide a string)
callback CallbackVFS Callback function
Returns:
The index of your watch (you can unwatch with this)
Type
Number

staticOSjs.VFS.write(item, data, callback, options, appRef)

Writes data to a file

Write File
Parameters:
Name Type Attributes Description
item OSjs.VFS.File File Metadata (you can also provide a string)
data File File Data (see supported types)
callback CallbackVFS Callback function
options Object <optional>
Set of options
appRef OSjs.Core.Application <optional>
Reference to an Application