QGIS API Documentation 3.37.0-Master (684a802617f)
Loading...
Searching...
No Matches
qgsfileutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfileutils.h
3 ---------------------------
4 begin : November 2017
5 copyright : (C) 2017 by Etienne Trimaille
6 email : etienne dot trimaille at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSFILEUTILS_H
19#define QGSFILEUTILS_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgis.h"
24#include <QString>
25
31class CORE_EXPORT QgsFileUtils
32{
33 public:
34
38 static QString representFileSize( qint64 bytes );
39
40
48 static QStringList extensionsFromFilter( const QString &filter );
49
56 static QString wildcardsFromFilter( const QString &filter );
57
66 static bool fileMatchesFilter( const QString &fileName, const QString &filter );
67
79 static QString ensureFileNameHasExtension( const QString &fileName, const QStringList &extensions );
80
92 static QString addExtensionFromFilter( const QString &fileName, const QString &filter );
93
100 static QString stringToSafeFilename( const QString &string );
101
108 static QString findClosestExistingPath( const QString &path );
109
120 static QStringList findFile( const QString &file, const QString &basepath = QString(), int maxClimbs = 4, int searchCeiling = 4, const QString &currentDir = QString() );
121
129 static Qgis::DriveType driveType( const QString &path ) SIP_THROW( QgsNotSupportedException );
130
137 static bool pathIsSlowDevice( const QString &path );
138
155 static QSet< QString > sidecarFilesForPath( const QString &path );
156
180 static bool renameDataset( const QString &oldPath, const QString &newPath, QString &error SIP_OUT, Qgis::FileOperationFlags flags = Qgis::FileOperationFlag::IncludeMetadataFile | Qgis::FileOperationFlag::IncludeStyleFile );
181
191 static int openedFileLimit() SIP_SKIP;
192
202 static int openedFileCount() SIP_SKIP;
203
215 static bool isCloseToLimitOfOpenedFiles( int filesToBeOpened = 1 ) SIP_SKIP;
216
225 static QStringList splitPathToComponents( const QString &path );
226
237 static QString uniquePath( const QString &path );
238
239};
240
241#endif // QGSFILEUTILS_H
DriveType
Drive types.
Definition qgis.h:877
@ IncludeMetadataFile
Indicates that any associated .qmd metadata file should be included with the operation.
@ IncludeStyleFile
Indicates that any associated .qml styling file should be included with the operation.
QFlags< FileOperationFlag > FileOperationFlags
File operation flags.
Definition qgis.h:1903
Class for file utilities.
Custom exception class which is raised when an operation is not supported.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_THROW(name,...)
Definition qgis_sip.h:203