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): string

Returns the file name of filePath up to (but not including) the first '.' character.

completeBaseName

FileInfo.completeBaseName(filePath: string): string

Returns the file name of filePath up to (but not including) the last '.' character.

fileName

FileInfo.fileName(filePath: string): string

Returns the last component of filePath, that is, everything after the last '/' character.

fromWindowsSeparators

FileInfo.fromWindowsSeparators(filePath: string): string

Returns 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.

toWindowsSeparators

FileInfo.toWindowsSeparators(filePath: string): string

Returns filePath with all '/' characters replaced by '\'.

© 2015 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.