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.
Available Operations
baseName
FileInfo.baseName(filePath: string): stringReturns the file name of filePath up to (but not including) the first '.' character.
canonicalPath
FileInfo.canonicalPath(filePath: string): stringReturns a canonicalized filePath, i.e. an absolute path without symbolic links or redundant "." or ".." elements. On Windows, drive substitutions are also resolved.
It is recommended to use canonicalPath in only those cases where canonical paths are really necessary. In most cases, cleanPath should be enough.
cleanPath
FileInfo.cleanPath(filePath: string): stringReturns filePath without redundant separators and with resolved occurrences of . and .. components. For instance, /usr/local//../bin/ becomes /usr/bin.
completeBaseName
FileInfo.completeBaseName(filePath: string): stringReturns the file name of filePath up to (but not including) the last '.' character.
completeSuffix
FileInfo.completeSuffix(filePath: string): stringReturns the file suffix of filePath from (but not including) the last '.' character.
This function was introduced in version 1.12.
fileName
FileInfo.fileName(filePath: string): stringReturns the last component of filePath, that is, everything after the last '/' character.
fromNativeSeparators
FileInfo.fromNativeSeparators(filePath: string): stringOn Windows hosts, this function behaves the same as fromWindowsSeparators. On other operating systems, it returns the input unmodified.
fromWindowsSeparators
FileInfo.fromWindowsSeparators(filePath: string): stringReturns filePath with all '\' characters replaced by '/'.
isAbsolutePath
FileInfo.isAbsolutePath(filePath: string, hostOS?: string[]): boolean
Returns true if filePath is an absolute path and false if it is a relative one. If hostOS is specified, treats filePath as a file path of the kind found on that platform. This parameter defaults to the host OS on which Qbs is running and should normally be omitted.
joinPaths
FileInfo.joinPaths(...paths: string[]): string
Concatenates the given paths using the '/' character.
path
FileInfo.path(filePath: string, hostOS?: string[]): string
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. If hostOS is specified, treats filePath as a file path of the kind found on that platform. This parameter defaults to the host OS on which Qbs is running and should normally be omitted.
relativePath
FileInfo.relativePath(dirPath: string, filePath: string): string
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.
suffix
FileInfo.suffix(filePath: string): stringReturns the file suffix of filePath from (but not including) the first '.' character.
This function was introduced in version 1.12.
toNativeSeparators
FileInfo.toNativeSeparators(filePath: string): stringOn Windows hosts, this function behaves the same as toWindowsSeparators. On other operating systems, it returns the input unmodified.
toWindowsSeparators
FileInfo.toWindowsSeparators(filePath: string): stringReturns filePath with all '/' characters replaced by '\'.
pathListSeparator
FileInfo.pathListSeparator(): stringReturns the host operating system separator for a path list that is used in environment variables or other contexts.
This function was introduced in version 1.22.
pathSeparator
FileInfo.pathSeparator(): stringReturns the host operating system path separator.
This function was introduced in version 1.22.
executableSuffix
FileInfo.executableSuffix(): stringReturns the host operating system executable suffix.
This function was introduced in version 1.23.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.