1 /******************************************************************* 2 3 Part of the Fritzing project - http://fritzing.org 4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de 5 6 Fritzing is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Fritzing is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Fritzing. If not, see <http://www.gnu.org/licenses/>. 18 19 ******************************************************************** 20 21 $Revision: 6912 $: 22 $Author: irascibl@gmail.com $: 23 $Date: 2013-03-09 08:18:59 +0100 (Sa, 09. Mrz 2013) $ 24 25 ********************************************************************/ 26 27 #ifndef FOLDERUTILS_H 28 #define FOLDERUTILS_H 29 30 #include <QString> 31 #include <QDir> 32 #include <QStringList> 33 #include <QFileDialog> 34 35 #include "misc.h" 36 37 class FolderUtils 38 { 39 40 public: 41 static QDir *getApplicationSubFolder(QString); 42 static QString getApplicationSubFolderPath(QString); 43 static QString getUserDataStorePath(QString folder = ___emptyString___); 44 static const QStringList & getUserDataStoreFolders(); 45 static bool createFolderAnCdIntoIt(QDir &dir, QString newFolder); 46 static bool setApplicationPath(const QString & path); 47 static const QString getLibraryPath(); 48 static QString getOpenFileName( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, QFileDialog::Options options = 0 ); 49 static QStringList getOpenFileNames( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, QFileDialog::Options options = 0 ); 50 static QString getSaveFileName( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, QFileDialog::Options options = 0 ); 51 static void setOpenSaveFolder(const QString& path); 52 static void setOpenSaveFolderAux(const QString& path); 53 static const QString openSaveFolder(); 54 static bool isEmptyFileName(const QString &filename, const QString &unsavedFilename); 55 static void rmdir(const QString &dirPath); 56 static void rmdir(QDir & dir); 57 static bool createZipAndSaveTo(const QDir &dirToCompress, const QString &filename, const QStringList & skipSuffixes); 58 static bool unzipTo(const QString &filepath, const QString &dirToDecompress, QString & error); 59 static void replicateDir(QDir srcDir, QDir targDir); 60 static void cleanup(); 61 static void collectFiles(const QDir & parent, QStringList & filters, QStringList & files, bool recursive); 62 static void makePartFolderHierarchy(const QString & prefixFolder, const QString & destFolder); 63 static void copyBin(const QString & source, const QString & dest); 64 static bool slamCopy(QFile &, const QString & dest); 65 static void showInFolder(const QString & path); 66 67 protected: 68 FolderUtils(); 69 ~FolderUtils(); 70 71 const QStringList & userDataStoreFolders(); 72 bool setApplicationPath2(const QString & path); 73 const QString applicationDirPath(); 74 const QString libraryPath(); 75 76 protected: 77 static FolderUtils* singleton; 78 static QString m_openSaveFolder; 79 80 protected: 81 QStringList m_folders; 82 QString m_appPath; 83 }; 84 85 #endif 86