File Service

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

Making the Service Available

To gain access to file system operations, import the service using the following statement at the top of your project file:

import qbs.File

Available Operations

copy

File.copy(sourceFilePath, targetFilePath)

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)

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

remove

File.remove(filePath)

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