File: qgsfileutils.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (243 lines) | stat: -rw-r--r-- 8,607 bytes parent folder | download | duplicates (12)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsfileutils.h                                              *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/




class QgsFileUtils
{
%Docstring(signature="appended")
Class for file utilities.
%End

%TypeHeaderCode
#include "qgsfileutils.h"
%End
  public:

    static QString representFileSize( qint64 bytes );
%Docstring
Returns the human size from bytes
%End


    static QStringList extensionsFromFilter( const QString &filter );
%Docstring
Returns a list of the extensions contained within a file ``filter``
string. E.g. a ``filter`` of ``GeoTIFF Files (*.tiff *.tif)`` would
return a list containing ``tiff``, ``tif``. The initial '.' is stripped
off the extension.

.. seealso:: :py:func:`ensureFileNameHasExtension`

.. seealso:: :py:func:`addExtensionFromFilter`
%End

    static QString wildcardsFromFilter( const QString &filter );
%Docstring
Given a ``filter`` string like ``GeoTIFF Files (*.tiff *.tif)``,
extracts the wildcard portion of this filter (i.e. ``*.tiff *.tif``).

.. versionadded:: 3.18
%End

    static bool fileMatchesFilter( const QString &fileName, const QString &filter );
%Docstring
Returns ``True`` if the given ``fileName`` matches a file ``filter``
string.

E.g a filter of ``GeoTIFF Files (*.tiff *.tif)`` would return ``True``
for a ``fileName`` of ``/home/test.tif``, or ``False`` for
``/home/test.jpg``.

.. versionadded:: 3.18
%End

    static QString ensureFileNameHasExtension( const QString &fileName, const QStringList &extensions );
%Docstring
Ensures that a ``fileName`` ends with an extension from the provided
list of ``extensions``.

E.g. if extensions contains ``tif`` and ``tiff``, then a ``fileName`` of
``d:/my_file`` will return ``d:/my_file.tif``. A ``fileName`` of
``d:/my_file.TIFF`` or ``d:/my_file.TIF`` will be returned unchanged.

.. seealso:: :py:func:`extensionsFromFilter`

.. seealso:: :py:func:`addExtensionFromFilter`
%End

    static QString addExtensionFromFilter( const QString &fileName, const QString &filter );
%Docstring
Ensures that a ``fileName`` ends with an extension from the specified
``filter`` string.

E.g. a ``fileName`` of ``d:/my_file`` with a filter of ``GeoTIFF Files
(*.tiff *.tif)`` will return ``d:/my_file.tif``, where as ``fileName``
of ``d:/my_file.TIFF`` or ``d:/my_file.TIF`` will be returned unchanged.

.. seealso:: :py:func:`extensionsFromFilter`

.. seealso:: :py:func:`ensureFileNameHasExtension`
%End

    static QString stringToSafeFilename( const QString &string );
%Docstring
Converts a ``string`` to a safe filename, replacing characters which are
not safe for filenames with an '_' character.

.. warning::

   This method strips slashes from the filename, so it is safe to call with file names only, not complete paths.
%End

    static QString findClosestExistingPath( const QString &path );
%Docstring
Returns the top-most existing folder from ``path``. E.g. if ``path`` is
``/home/user/projects/2018/P4343`` and ``/home/user/projects`` exists
but no ``2018`` subfolder exists, then the function will return
``/home/user/projects``.

.. versionadded:: 3.2
%End

    static QStringList findFile( const QString &file, const QString &basepath = QString(), int maxClimbs = 4, int searchCeiling = 4, const QString &currentDir = QString() );
%Docstring
Will check ``basepath`` in an outward spiral up to ``maxClimbs`` levels
to check if ``file`` exists.

:param file: Name or full path of the file to find
:param basepath: current basepath of the file, needed if only the name
                 is specified in file
:param maxClimbs: limit the number of time the search can move up from
                  the basepath
:param searchCeiling: limits where in the folder hierarchy the search
                      can be performed, 1 = root/drive, 2 = first folder
                      level, 3 = sub folders ( Unix: /usr/bin, Win:
                      C:/Users/Admin ), etc.
:param currentDir: alternative default directory to override the actual
                   current directory during the search

:return: List of strings of the first matching path in unix format.

.. versionadded:: 3.12
%End

    static Qgis::DriveType driveType( const QString &path ) throw( QgsNotSupportedException );
%Docstring
Returns the drive type for the given ``path``.

:raises QgsNotSupportedException: if determining the drive type is not
                                  supported on the current platform.

.. versionadded:: 3.20
%End

    static bool pathIsSlowDevice( const QString &path );
%Docstring
Returns ``True`` if the specified ``path`` is assumed to reside on a
slow device, e.g. a remote network drive or other non-fixed device.

.. versionadded:: 3.20
%End

    static QSet< QString > sidecarFilesForPath( const QString &path );
%Docstring
Returns a list of the sidecar files which exist for the dataset a the
specified ``path``.

In this context a sidecar file is defined as a file which shares the
same base filename as a dataset, but which differs in file extension. It
defines the list of additional files which must be renamed or deleted
alongside the main file associated with the dataset in order to
completely rename/delete the dataset.

For instance, if ``path`` specified a .shp file then the corresponding
.dbf, .idx and .prj files would be returned (amongst others).

.. note::

   QGIS metadata files (.qmd) and map layer styling files (.qml) are NOT included
   in the returned list.

.. versionadded:: 3.22
%End

    static bool renameDataset( const QString &oldPath, const QString &newPath, QString &error /Out/, Qgis::FileOperationFlags flags = Qgis::FileOperationFlag::IncludeMetadataFile | Qgis::FileOperationFlag::IncludeStyleFile );
%Docstring
Renames the dataset at ``oldPath`` to ``newPath``, renaming both the
file at ``oldPath`` and all associated sidecar files which exist for it.

For instance, if ``oldPath`` specified a .shp file then the
corresponding .dbf, .idx and .prj files would be renamed (amongst
others).

The destination directory must already exist.

The optional ``flags`` argument can be used to control whether QMD
metadata files and QML styling files should also be renamed accordingly.
By default these will be renamed, but manually specifying a different
set of flags allows callers to avoid this when desired.

:param oldPath: original path to dataset
:param newPath: new path for dataset
:param flags: optional flags to control file operation behavior

:return: - ``True`` if the dataset was successfully renamed, or
           ``False`` if an error occurred
         - error: a descriptive error message if the rename operation
           fails

.. versionadded:: 3.22
%End




    static QStringList splitPathToComponents( const QString &path );
%Docstring
Given a file ``path``, returns a list of all the components leading to
that path.

E.g. if ``path`` is ``/home/user/Pictures/test.png``, the returned list
will contain ``/`` , ``home``, ``user``, ``Pictures``, ``test.png``.

.. versionadded:: 3.28
%End

    static QString uniquePath( const QString &path );
%Docstring
Creates a unique file path name from a desired path by appending
``_<n>`` (where ``<n>`` is an integer number) before the file suffix.

E.g. if ``/path/my_image.png`` already exists ``/path/my_image_2.png``
(and ``_3`, ``_4`` etc.) will be checked until a file path that does not
already exist is found.

:param path: the desired path.

:return: the unmodified path if path is already unique or the new path
         with ``_<n>`` (where ``<n>`` is an integer number) appended to
         the file name before the suffix.

.. note::

   This function does not make any check on path validity and write permissions.

.. versionadded:: 3.30
%End

};

/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsfileutils.h                                              *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/