File Service

The File service offers limited access to the file system for operations such as copying or removing files.

Available Operations

copy

File.copy(sourceFilePath: string, targetFilePath: string): boolean

Copies sourceFilePath to targetFilePath. Any directory components in targetFilePath that do not yet exist will be created. If sourceFilePath is a directory, a recursive copy will be made. If an error occurs, a JavaScript exception will be thrown.

Note: targetFilePath must be the counterpart of sourceFilePath at the new location, not the new parent directory. This allows the copy to have a different name and is true even if sourceFilePath is a directory.

exists

File.exists(filePath: string): boolean

Returns true if and only if there is a file at filePath.

lastModified

File.lastModified(filePath: string): number

Returns the time of last modification for the file at filePath. The concrete semantics of the returned value are platform-specific. You should only rely on the property that a smaller value indicates an older timestamp.

makePath

File.makePath(path: string): boolean

Makes the directory at path, creating intermediate directories if necessary. Conceptually equivalent to mkdir -p

remove

File.remove(filePath: string): boolean

Removes the file at filePath. In case of a directory, it will be removed recursively.