aboutsummaryrefslogtreecommitdiffstats
path: root/doc/reference/jsextensions/jsextension-fileinfo.qdoc
blob: cb0eb7c432629bddc86c1e2f44481005791c4d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \page jsextension-fileinfo.html
    \ingroup list-of-builtin-services

    \title FileInfo Service
    \brief Provides operations on file paths.

    The \c 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.

    \section1 Available Operations

    \section2 baseName
    \code
    FileInfo.baseName(filePath: string): string
    \endcode
    Returns the file name of \c filePath up to (but not including) the first '.' character.

    \section2 canonicalPath
    \code
    FileInfo.canonicalPath(filePath: string): string
    \endcode
    Returns a canonicalized \c 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 \c{canonicalPath} in only those cases where
    canonical paths are really necessary. In most cases, \c{cleanPath} should
    be enough.

    \section2 cleanPath
    \code
    FileInfo.cleanPath(filePath: string): string
    \endcode
    Returns \c filePath without redundant separators and with resolved occurrences of
    \c{.} and \c{..} components. For instance, \c{/usr/local//../bin/} becomes \c{/usr/bin}.

    \section2 completeBaseName
    \code
    FileInfo.completeBaseName(filePath: string): string
    \endcode
    Returns the file name of \c filePath up to (but not including) the last '.' character.

    \section2 completeSuffix
    \code
    FileInfo.completeSuffix(filePath: string): string
    \endcode
    Returns the file suffix of \c filePath from (but not including) the last '.' character.
    \funsince 1.12

    \section2 fileName
    \code
    FileInfo.fileName(filePath: string): string
    \endcode
    Returns the last component of \c filePath, that is, everything after the
    last '/' character.

    \section2 fromNativeSeparators
    \code
    FileInfo.fromNativeSeparators(filePath: string): string
    \endcode
    On Windows hosts, this function behaves the same as \l fromWindowsSeparators. On other
    operating systems, it returns the input unmodified.

    \section2 fromWindowsSeparators
    \code
    FileInfo.fromWindowsSeparators(filePath: string): string
    \endcode
    Returns \c filePath with all '\\' characters replaced by '/'.

    \section2 isAbsolutePath
    \code
    FileInfo.isAbsolutePath(filePath: string, hostOS?: string[]): boolean
    \endcode
    Returns true if \c filePath is an absolute path and false if it is a relative one.
    If \c hostOS is specified, treats \c 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.

    \section2 joinPaths
    \code
    FileInfo.joinPaths(...paths: string[]): string
    \endcode
    Concatenates the given paths using the '/' character.

    \section2 path
    \code
    FileInfo.path(filePath: string, hostOS?: string[]): string
    \endcode
    Returns the part of \c filePath that is not the file name, that is,
    everything up to
    (but not including) the last '/' character. If \c filePath is just a file name, then '.'
    is returned. If \c filePath ends with a '/' character, then the file name is assumed to be empty
    for the purpose of the above definition.
    If \c hostOS is specified, treats \c 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.

    \section2 relativePath
    \code
    FileInfo.relativePath(dirPath: string, filePath: string): string
    \endcode
    Returns a relative path so that joining \c dirPath and the returned path results in \c filePath.
    If necessary, '..' components are inserted.
    The function assumes \c dirPath and \c filePath to be absolute paths and \c dirPath to
    be a directory.

    \section2 suffix
    \code
    FileInfo.suffix(filePath: string): string
    \endcode
    Returns the file suffix of \c filePath from (but not including) the first '.' character.
    \funsince 1.12

    \section2 toNativeSeparators
    \code
    FileInfo.toNativeSeparators(filePath: string): string
    \endcode
    On Windows hosts, this function behaves the same as \l toWindowsSeparators. On other
    operating systems, it returns the input unmodified.

    \section2 toWindowsSeparators
    \code
    FileInfo.toWindowsSeparators(filePath: string): string
    \endcode
    Returns \c filePath with all '/' characters replaced by '\\'.

    \section2 pathListSeparator
    \code
    FileInfo.pathListSeparator(): string
    \endcode
    Returns the host operating system separator for a path list that is used in environment
    variables or other contexts.
    \funsince 1.22

    \section2 pathSeparator
    \code
    FileInfo.pathSeparator(): string
    \endcode
    Returns the host operating system path separator.
    \funsince 1.22
*/