/
qgsfileutils.sip.in
129 lines (94 loc) · 4.76 KB
/
qgsfileutils.sip.in
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
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfileutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsFileUtils
{
%Docstring
Class for file utilities.
.. versionadded:: 3.0
%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 ¤tDir = 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
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfileutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/