|
swift
|
Utility class for file operations. More...
Static Public Member Functions | |
| static const QString & | jsonAppendix () |
| Our JSON file name appendix. | |
| static const QString & | jsonWildcardAppendix () |
| JSON wildcard + appendix. | |
| static bool | writeStringToFile (const QString &content, const QString &fileNameAndPath) |
| Write string to text file. | |
| static bool | writeStringToLockedFile (const QString &content, const QString &fileNameAndPath) |
| Write string to file, with a lock so two applications can't access at the same time. | |
| static QString | readFileToString (const QString &fileNameAndPath) |
| Read file into string. | |
| static QString | readLockedFileToString (const QString &fileNameAndPath) |
| Read file into string, with a lock so two applications can't access at the same time. | |
| static QString | readFileToString (const QString &filePath, const QString &fileName) |
| Read file into string. | |
| static QString | readLockedFileToString (const QString &filePath, const QString &fileName) |
| Read file into string, with a lock so two applications can't access at the same time. | |
| static bool | writeByteArrayToFile (const QByteArray &data, const QString &fileNameAndPath) |
| Write byte array to file. | |
| static QString | appendFilePaths (const QString &path1, const QString &path2) |
| Append file paths. More... | |
| static QString | appendFilePathsAndFixUnc (const QString &path1, const QString &path2) |
| Append file paths. More... | |
| static QString | appendFilePaths (const QString &path1, const QString &path2, const QString &path3) |
| Append file paths. More... | |
| static QString | appendFilePathsAndFixUnc (const QString &path1, const QString &path2, const QString &path3) |
| Append file paths. More... | |
| static QString | pathUp (const QString &path) |
| One path up. | |
| static QString | stripFileFromPath (const QString &path) |
| Strip file from path a/b/c.json a/b, return path. | |
| static QString | stripFirstSlashPart (const QString &path) |
| Strip first slash part "/a/b" => "a/b", "h:/foo" => foo. | |
| static QStringList | stripFirstSlashParts (const QStringList &paths) |
| Strip first slash part "/a/b" => "a/b", "h:/foo" => foo. | |
| static QString | stripLeadingSlashOrDriveLetter (const QString &path) |
| Strip leading slash or drive letter "/a/b" => "a/b" "H:/Foo" => "Foo". | |
| static QStringList | stripLeadingSlashOrDriveLetters (const QStringList &paths) |
| Strip first slash part "/a/b" => "a/b", "h:/foo" => foo. | |
| static QString | lastPathSegment (const QString &path) |
| Last path segment a/b/c => c. | |
| static QString | normalizeFilePathToQtStandard (const QString &filePath) |
| Normalize file path to Qt standard, e.g by turning \ to /. | |
| static QStringList | makeDirectoriesRelative (const QStringList &directories, const QString &rootDirectory, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Make directory paths relative to root directory. More... | |
| static bool | sameDirectories (const QStringList &dirs1, const QStringList &dirs2, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Same directories, order in list does not matter and lists are cleaned up. | |
| static Qt::CaseSensitivity | osFileNameCaseSensitivity () |
| Case sensitivity for current OS. | |
| static bool | isFileNameCaseSensitive () |
| Case sensitive file names. | |
| static bool | matchesExcludeDirectory (const QString &directoryPath, const QString &excludePattern, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Is directory path matching the exclude path? | |
| static bool | isExcludedDirectory (const QDir &directory, const QStringList &excludeDirectories, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Directory to be excluded? | |
| static bool | isExcludedDirectory (const QFileInfo &fileInfo, const QStringList &excludeDirectories, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Directory to be excluded? | |
| static bool | isExcludedDirectory (const QString &directoryPath, const QStringList &excludeDirectories, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Directory to be excluded? | |
| static QStringList | removeSubDirectories (const QStringList &directories, Qt::CaseSensitivity cs=osFileNameCaseSensitivity()) |
| Removes sub directories in list: A/B A/B/C B B/D -> A/B B returned. | |
| static QString | findFirstExisting (const QStringList &filesOrDirectory) |
| Find first existing file or directory (means exists on file system) | |
| static QString | findFirstFile (const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}, std::function< bool(const QFileInfo &)> predicate={}) |
| Returns path to first file in dir which matches the optional wildcard and predicate, or empty string. | |
| static bool | containsFile (const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}, std::function< bool(const QFileInfo &)> predicate={}) |
| True if there exists a file in dir which matches the optional wildcard and predicate. | |
| static QString | findFirstNewerThan (const QDateTime &time, const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}) |
| Returns path to first file in dir newer than the given time, optionally matching a wildcard, or empty string. | |
| static bool | containsFileNewerThan (const QDateTime &time, const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}) |
| True if there exists a file in dir newer than the given time, optionally matching a wildcard. | |
| static QFileInfoList | enumerateFiles (const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}, std::function< bool(const QFileInfo &)> predicate={}) |
| Returns list of all files in dir, optionally matching a wildcard and predicate. | |
| static QFileInfo | findLastModified (const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}) |
| Returns path to the last modifed file in dir, optionally matching a wildcard, or empty string. | |
| static QFileInfo | findLastCreated (const QDir &dir, bool recursive, const QStringList &nameFilters={}, const QStringList &excludeDirectories={}) |
| Returns path to the last created file in dir, optionally matching a wildcard, or empty string. | |
| static const QStringList & | getSwiftExecutables () |
| Get all swift executables. | |
| static QStringList | getBaseNamesOnly (const QStringList &fileNames) |
| Turn paths and filenames in base names only. | |
| static QStringList | getFileNamesOnly (const QStringList &fileNames) |
| Turn paths and filenames in file names only. | |
| static QString | lockFileError (const QLockFile &lockFile) |
| Error message explaining why a QLockFile failed to lock. | |
| static QString | fixWindowsUncPath (const QString &filePath) |
| UNC file paths on Qt start with "/", but UNC file paths only work when they start with "//". More... | |
| static QStringList | fixWindowsUncPaths (const QStringList &filePaths) |
| Fix UNC file paths. More... | |
| static bool | isWindowsUncPath (const QString &filePath) |
| Windows UNC path? | |
| static QString | windowsUncMachine (const QString &filePath) |
| Machine in Windows UNC path. | |
| static QSet< QString > | windowsUncMachines (const QSet< QString > &paths) |
| All UNC machines from the paths. | |
| static QString | toWindowsLocalPath (const QString &path) |
| To Windows path using "\" delimiter. | |
| static QString | humanReadableFileSize (qint64 size) |
| Human readable (GB, MB, ..) file size. | |
| static const QStringList & | executableSuffixes () |
| Executable file name appendixes. | |
| static bool | isExecutableFile (const QString &fileName) |
| Executable file (decided by appendix) | |
| static bool | isSwiftInstaller (const QString &fileName) |
| swift installer | |
Utility class for file operations.
Definition at line 28 of file fileutils.h.
|
static |
Append file paths.
Definition at line 95 of file fileutils.cpp.
|
static |
Append file paths.
Definition at line 159 of file fileutils.cpp.
|
static |
Append file paths.
Definition at line 108 of file fileutils.cpp.
|
static |
Append file paths.
Definition at line 164 of file fileutils.cpp.
UNC file paths on Qt start with "/", but UNC file paths only work when they start with "//".
Definition at line 438 of file fileutils.cpp.
|
static |
Fix UNC file paths.
Definition at line 447 of file fileutils.cpp.
|
static |
Make directory paths relative to root directory.
Definition at line 187 of file fileutils.cpp.