2017-11-29 13:10:26 +01:00
|
|
|
/************************************************************************
|
|
|
|
* 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
|
2018-05-26 14:10:30 +10:00
|
|
|
Class for file utilities.
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-11-29 13:10:26 +01:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsfileutils.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
static QString representFileSize( qint64 bytes );
|
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns the human size from bytes
|
2017-11-29 13:10:26 +01:00
|
|
|
%End
|
|
|
|
|
2017-12-18 09:05:59 +10:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`ensureFileNameHasExtension`
|
2017-12-18 09:05:59 +10:00
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`addExtensionFromFilter`
|
2017-12-18 09:05:59 +10:00
|
|
|
%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.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`extensionsFromFilter`
|
2017-12-18 09:05:59 +10:00
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`addExtensionFromFilter`
|
2017-12-18 09:05:59 +10:00
|
|
|
%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.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`extensionsFromFilter`
|
2017-12-18 09:05:59 +10:00
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`ensureFileNameHasExtension`
|
2017-12-19 10:59:27 +10:00
|
|
|
%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.
|
|
|
|
|
2018-03-05 10:33:15 +10:00
|
|
|
.. warning::
|
|
|
|
|
|
|
|
This method strips slashes from the filename, so it is safe to call with file names only, not complete paths.
|
2018-06-22 10:45:00 +10:00
|
|
|
%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
|
2017-12-18 09:05:59 +10:00
|
|
|
%End
|
2017-11-29 13:10:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsfileutils.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|