refactor: rename DGioUtils to DGlibUtils

This commit is contained in:
Gary Wang 2019-08-01 13:54:05 +08:00
parent 49b63c6ed5
commit 6da5444c17
4 changed files with 19 additions and 16 deletions

View File

@ -4,13 +4,13 @@
configure_file ("gio-qt.pc.in" "gio-qt.pc" @ONLY) configure_file ("gio-qt.pc.in" "gio-qt.pc" @ONLY)
set (QGIO_PUBLIC_HEADER_FILES set (QGIO_PUBLIC_HEADER_FILES
include/dglibutils.h
include/dgiovolumemanager.h include/dgiovolumemanager.h
include/dgiomountoperation.h include/dgiomountoperation.h
include/dgiomount.h include/dgiomount.h
include/dgiovolume.h include/dgiovolume.h
include/dgiofile.h include/dgiofile.h
include/dgiofileinfo.h include/dgiofileinfo.h
include/dgioutils.h
include/dgiofileiterator.h include/dgiofileiterator.h
include/dgiodrive.h include/dgiodrive.h
) )
@ -20,13 +20,13 @@ set (QGIO_PRIVATE_HEADER_FILES
) )
set (QGIO_PRIVATE_CPP_FILES set (QGIO_PRIVATE_CPP_FILES
source/dglibutils.cpp
source/dgiovolumemanager.cpp source/dgiovolumemanager.cpp
source/dgiomountoperation.cpp source/dgiomountoperation.cpp
source/dgiomount.cpp source/dgiomount.cpp
source/dgiovolume.cpp source/dgiovolume.cpp
source/dgiofile.cpp source/dgiofile.cpp
source/dgiofileinfo.cpp source/dgiofileinfo.cpp
source/dgioutils.cpp
source/dgiofileiterator.cpp source/dgiofileiterator.cpp
source/dgiodrive.cpp source/dgiodrive.cpp
private/dgiohelper.cpp private/dgiohelper.cpp

View File

@ -18,12 +18,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DGIOUTILS_H #ifndef DGLIBUTILS_H
#define DGIOUTILS_H #define DGLIBUTILS_H
#include <QObject> #include <QObject>
enum DGioUserDirectory enum DGlibUserDirectory
{ {
USER_DIRECTORY_DESKTOP, USER_DIRECTORY_DESKTOP,
USER_DIRECTORY_DOCUMENTS, USER_DIRECTORY_DOCUMENTS,
@ -35,15 +35,15 @@ enum DGioUserDirectory
USER_DIRECTORY_VIDEOS, USER_DIRECTORY_VIDEOS,
USER_N_DIRECTORIES USER_N_DIRECTORIES
}; };
Q_ENUMS(DGioUserDirectory); Q_ENUMS(DGlibUserDirectory);
class DGioUtils class DGlibUtils
{ {
public: public:
static QString userSpecialDir(DGioUserDirectory userDirectory); static QString userSpecialDir(DGlibUserDirectory userDirectory);
static QStringList systemDataDirs(); static QStringList systemDataDirs();
static QString userDataDir(); static QString userDataDir();
static QString tmpDir(); static QString tmpDir();
}; };
#endif // DGIOUTILS_H #endif // DGLIBUTILS_H

View File

@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "dgioutils.h" #include "dglibutils.h"
#include <QStringList> #include <QStringList>
@ -32,8 +32,11 @@
* *
* On UNIX platforms this is determined using the mechanisms described in the * On UNIX platforms this is determined using the mechanisms described in the
* [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec). * [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
*
* \param userDirectory The logical id of special directory.
* \return The path to the specified special directory, or an empty string if the logical id was not found.
*/ */
QString DGioUtils::userSpecialDir(DGioUserDirectory userDirectory) QString DGlibUtils::userSpecialDir(DGlibUserDirectory userDirectory)
{ {
return QString::fromStdString(Glib::get_user_special_dir(static_cast<Glib::UserDirectory>(userDirectory))); return QString::fromStdString(Glib::get_user_special_dir(static_cast<Glib::UserDirectory>(userDirectory)));
} }
@ -48,7 +51,7 @@ QString DGioUtils::userSpecialDir(DGioUserDirectory userDirectory)
* [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec) * [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec)
* In this case the list of directories retrieved will be XDG_DATA_DIRS. * In this case the list of directories retrieved will be XDG_DATA_DIRS.
*/ */
QStringList DGioUtils::systemDataDirs() QStringList DGlibUtils::systemDataDirs()
{ {
std::vector<std::string> dirs = Glib::get_system_data_dirs(); std::vector<std::string> dirs = Glib::get_system_data_dirs();
QStringList lst; QStringList lst;
@ -70,7 +73,7 @@ QStringList DGioUtils::systemDataDirs()
* [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec). * [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
* In this case the directory retrieved will be `XDG_DATA_HOME`. * In this case the directory retrieved will be `XDG_DATA_HOME`.
*/ */
QString DGioUtils::userDataDir() QString DGlibUtils::userDataDir()
{ {
return QString::fromStdString(Glib::get_user_data_dir()); return QString::fromStdString(Glib::get_user_data_dir());
} }
@ -86,7 +89,7 @@ QString DGioUtils::userDataDir()
* *
* \return The directory to use for temporary files. * \return The directory to use for temporary files.
*/ */
QString DGioUtils::tmpDir() QString DGlibUtils::tmpDir()
{ {
return QString::fromStdString(Glib::get_tmp_dir()); return QString::fromStdString(Glib::get_tmp_dir());
} }

View File

@ -22,8 +22,8 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QExplicitlySharedDataPointer> #include <QExplicitlySharedDataPointer>
#include <dglibutils.h>
#include <dgiofile.h> #include <dgiofile.h>
#include <dgioutils.h>
#include <dgiomount.h> #include <dgiomount.h>
#include <dgiovolume.h> #include <dgiovolume.h>
#include <dgiodrive.h> #include <dgiodrive.h>
@ -33,7 +33,7 @@
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
qDebug() << DGioUtils::systemDataDirs(); qDebug() << DGlibUtils::systemDataDirs();
qDebug() << "----------------------"; qDebug() << "----------------------";