FileInfo Service
The FileInfo service offers various operations on file paths, such as turning absolute paths into relative ones, splitting a path into its components, and so on.
Making the Service Available
In order to gain access to file path operations, you need to import the service using the following statement at the top of your project file:
import qbs.FileInfo
Available Operations
baseName
FileInfo.baseName(filePath)
Returns the file name of filePath up to (but not including) the first '.' character.
completeBaseName
FileInfo.completeBaseName(filePath)
Returns the file name of filePath up to (but not including) the last '.' character.
fileName
FileInfo.fileName(filePath)
Returns the last component of filePath, that is, everything after the last '/' character.
fromWindowsSeparators
FileInfo.fromWindowsSeparators(filePath)
Returns filePath with all '\' characters replaced by '/'.
isAbsolutePath
FileInfo.isAbsolutPath(filePath)
Returns true if filePath is an absolute path and false if it is a relative one.
joinPaths
FileInfo.joinPaths(path1, path2, ...)
Concatenates the given paths using the '/' character.
path
FileInfo.path(filePath)
Returns the part of filePath that is not the file name, that is, everything up to (but not including) the last '/' character. If filePath is just a file name, then '.' is returned. If filePath ends with a '/' character, then the file name is assumed to be empty for the purpose of the above definition.
relativePath
FileInfo.relativePath(dirPath, filePath)
Returns a relative path so that joining dirPath and the returned path results in filePath. If necessary, '..' components are inserted. The function assumes dirPath and filePath to be absolute paths and dirPath to be a directory.
toWindowsSeparators
FileInfo.toWindowsSeparators(filePath)
Returns filePath with all '/' characters replaced by '\'.