KDECore
kstandarddirs.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the KDE libraries 00003 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> 00004 Copyright (C) 1999 Stephan Kulow <coolo@kde.org> 00005 Copyright (C) 1999 Waldo Bastian <bastian@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef KSTANDARDDIRS_H 00024 #define KSTANDARDDIRS_H 00025 00026 #include <QtCore/QStringList> 00027 #include <kglobal.h> 00028 #include <QtCore/QMap> 00029 00030 class KConfig; 00031 00171 class KDECORE_EXPORT KStandardDirs 00172 { 00173 public: 00188 KStandardDirs(); 00189 00190 enum SearchOption { NoSearchOptions = 0, 00191 Recursive = 1, 00192 NoDuplicates = 2, 00193 IgnoreExecBit = 4 }; 00194 Q_DECLARE_FLAGS( SearchOptions, SearchOption ) 00195 00196 00199 virtual ~KStandardDirs(); 00200 00210 void addPrefix( const QString& dir ); 00211 00219 void addXdgConfigPrefix( const QString& dir ); 00220 00228 void addXdgDataPrefix( const QString& dir ); 00229 00253 #ifndef KDE_NO_DEPRECATED 00254 KDE_DEPRECATED bool addResourceType( const char *type, 00255 const QString& relativename, bool priority = true ); 00256 #endif 00257 00279 bool addResourceType( const char *type, const char *basetype, 00280 const QString& relativename, bool priority = true ); 00281 00283 bool addResourceType( const char *type, const char *basetype, 00284 const char* relativename, bool priority = true ) 00285 { 00286 return addResourceType(type, basetype, QLatin1String(relativename), priority); 00287 } 00288 00306 bool addResourceDir( const char *type, 00307 const QString& absdir, bool priority = true ); 00308 00336 QString findResource( const char *type, 00337 const QString& filename ) const; 00338 00353 bool isRestrictedResource( const char *type, 00354 const QString& relPath=QString() ) const; 00355 00369 quint32 calcResourceHash( const char *type, 00370 const QString& filename, 00371 SearchOptions options = NoSearchOptions) const; 00372 00391 QStringList findDirs( const char *type, 00392 const QString& reldir ) const; 00393 00414 QString findResourceDir( const char *type, 00415 const QString& filename) const; 00416 00417 00438 QStringList findAllResources( const char *type, 00439 const QString& filter = QString(), 00440 SearchOptions options = NoSearchOptions ) const; 00441 00470 QStringList findAllResources( const char *type, 00471 const QString& filter, 00472 SearchOptions options, 00473 QStringList &relPaths) const; 00474 00484 static QStringList systemPaths( const QString& pstr=QString() ); 00485 00506 static QString findExe( const QString& appname, 00507 const QString& pathstr = QString(), 00508 SearchOptions options = NoSearchOptions ); 00509 00528 static int findAllExe( QStringList& list, const QString& appname, 00529 const QString& pathstr=QString(), 00530 SearchOptions options = NoSearchOptions ); 00531 00541 bool addCustomized(KConfig *config); 00542 00554 QStringList resourceDirs(const char *type) const; 00555 00562 QStringList allTypes() const; 00563 00581 QString saveLocation(const char *type, 00582 const QString& suffix = QString(), 00583 bool create = true) const; 00584 00600 QString relativeLocation(const char *type, const QString &absPath); 00601 00612 static bool makeDir(const QString& dir, int mode = 0755); 00613 00652 #ifndef KDE_NO_DEPRECATED 00653 static KDE_DEPRECATED QString kde_default(const char *type); 00654 #endif 00655 00659 QString kfsstnd_prefixes(); 00660 00664 QString kfsstnd_xdg_conf_prefixes(); 00665 00669 QString kfsstnd_xdg_data_prefixes(); 00670 00677 QString localkdedir() const; 00678 00683 QString localxdgdatadir() const; 00684 00689 QString localxdgconfdir() const; 00690 00695 static QString installPath(const char *type); 00696 00704 static bool exists(const QString &fullPath); 00705 00713 static QString realPath(const QString &dirname); 00714 00722 static QString realFilePath(const QString &filename); 00723 00735 static QString locate( const char *type, const QString& filename, const KComponentData &cData = KGlobal::mainComponent() ); 00736 00751 static QString locateLocal( const char *type, const QString& filename, const KComponentData &cData = KGlobal::mainComponent() ); 00752 00769 static QString locateLocal( const char *type, const QString& filename, bool createDir, const KComponentData &cData = KGlobal::mainComponent() ); 00770 00787 static bool checkAccess(const QString& pathname, int mode); 00788 00789 private: 00790 // Disallow assignment and copy-construction 00791 KStandardDirs( const KStandardDirs& ); 00792 KStandardDirs& operator= ( const KStandardDirs& ); 00793 00794 class KStandardDirsPrivate; 00795 KStandardDirsPrivate* const d; 00796 00797 // Like their public counter parts but with an extra priority argument 00798 // If priority is true, the directory is added directly after 00799 // $KDEHOME/$XDG_DATA_HOME/$XDG_CONFIG_HOME 00800 void addPrefix( const QString& dir, bool priority ); 00801 void addXdgConfigPrefix( const QString& dir, bool priority ); 00802 void addXdgDataPrefix( const QString& dir, bool priority ); 00803 void addKDEDefaults(); 00804 00805 void addResourcesFrom_krcdirs(); 00806 }; 00807 00808 Q_DECLARE_OPERATORS_FOR_FLAGS(KStandardDirs::SearchOptions) 00809 00810 #endif // KSTANDARDDIRS_H
KDE 4.6 API Reference