File indexing completed on 2024-06-16 04:38:24

0001 /*
0002     SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar>
0003     SPDX-FileCopyrightText: 2010-2022 Mladen Milinkovic <max@smoothware.net>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef COMMONDEFS_H
0009 #define COMMONDEFS_H
0010 
0011 #include <QString>
0012 #include <QStringList>
0013 
0014 #include <QUrl>
0015 
0016 class String
0017 {
0018 public:
0019     static QString title(const QString &text);
0020     static QString capitalize(const QString &text);
0021     static QString sentence(const QString &text);
0022 
0023 protected:
0024     static int rfindFunctionStart(const QString &text);
0025     static int rfindFunctionEnd(const QString &text, int startPos);
0026 };
0027 
0028 class System
0029 {
0030 public:
0031     // returns false on error
0032     static bool copy(const QString &srcPath, const QString &dstPath);
0033     static bool move(const QString &srcPath, const QString &dstPath);
0034     static bool remove(const QString &path);
0035     static bool recursiveMakeDir(const QString &path, QStringList *createdDirsList = 0);
0036 
0037     static bool isReadable(const QString &path);
0038     static bool isWritable(const QString &path);
0039 
0040     static QString homeDir();
0041     static QString tempDir();
0042 
0043     static QUrl urlFromPath(const QString &path);
0044 
0045     static QUrl newUrl(const QUrl &baseUrl, const QString &fileName = QStringLiteral("tempfile"), const QString &extension = QString(), int retries = 10);
0046 
0047     static bool urlIsInside(const QUrl &url, const QString &path);
0048     static bool urlIsInside(const QUrl &url, QStringList &path);
0049 };
0050 
0051 #endif