kstandarddirs.h
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 SSK_KSTDDIRS_H 00024 #define SSK_KSTDDIRS_H 00025 00026 #include <tqstring.h> 00027 #include <tqdict.h> 00028 #include <tqstringlist.h> 00029 #include <tdeglobal.h> 00030 00031 class TDEConfig; 00032 class TDEStandardDirsPrivate; 00033 00125 class TDECORE_EXPORT TDEStandardDirs 00126 { 00127 public: 00131 TDEStandardDirs( ); 00132 00136 virtual ~TDEStandardDirs(); 00137 00147 void addPrefix( const TQString& dir ); 00148 00156 void addXdgConfigPrefix( const TQString& dir ); 00157 00165 void addXdgDataPrefix( const TQString& dir ); 00166 00186 bool addResourceType( const char *type, 00187 const TQString& relativename ); 00188 00204 bool addResourceDir( const char *type, 00205 const TQString& absdir); 00206 00225 TQString findResource( const char *type, 00226 const TQString& filename ) const; 00227 00243 bool isRestrictedResource( const char *type, 00244 const TQString& relPath=TQString::null ) const; 00245 00258 TQ_UINT32 calcResourceHash( const char *type, 00259 const TQString& filename, bool deep) const; 00260 00277 TQStringList findDirs( const char *type, 00278 const TQString& reldir ) const; 00279 00300 TQString findResourceDir( const char *type, 00301 const TQString& filename) const; 00302 00303 00323 TQStringList findAllResources( const char *type, 00324 const TQString& filter = TQString::null, 00325 bool recursive = false, 00326 bool unique = false) const; 00327 00350 TQStringList findAllResources( const char *type, 00351 const TQString& filter, 00352 bool recursive, 00353 bool unique, 00354 TQStringList &relPaths) const; 00355 00365 static TQStringList systemPaths( const TQString& pstr=TQString::null ); 00366 00384 static TQString findExe( const TQString& appname, 00385 const TQString& pathstr=TQString::null, 00386 bool ignoreExecBit=false ); 00387 00406 static int findAllExe( TQStringList& list, const TQString& appname, 00407 const TQString& pathstr=TQString::null, 00408 bool ignoreExecBit=false ); 00409 00419 void addKDEDefaults(); 00420 00430 bool addCustomized(TDEConfig *config); 00431 00443 TQStringList resourceDirs(const char *type) const; 00444 00451 TQStringList allTypes() const; 00452 00470 TQString saveLocation(const char *type, 00471 const TQString& suffix = TQString::null, 00472 bool create = true) const; 00473 00489 TQString relativeLocation(const char *type, const TQString &absPath); 00490 00501 static bool makeDir(const TQString& dir, int mode = 0755); 00502 00530 static TQString kde_default(const char *type); 00531 00535 TQString kfsstnd_prefixes(); 00536 00540 TQString kfsstnd_xdg_conf_prefixes(); 00541 00545 TQString kfsstnd_xdg_data_prefixes(); 00546 00553 TQString localtdedir() const; 00554 00559 static TQString kfsstnd_defaultprefix(); 00560 00565 static TQString kfsstnd_defaultbindir(); 00566 00571 TQString localxdgdatadir() const; 00572 00577 TQString localxdgconfdir() const; 00578 00586 static bool exists(const TQString &fullPath); 00587 00596 static TQString realPath(const TQString &dirname); 00597 00606 static TQString realFilePath(const TQString &filename); 00607 00608 private: 00609 00610 TQStringList prefixes; 00611 00612 // Directory dictionaries 00613 TQDict<TQStringList> absolutes; 00614 TQDict<TQStringList> relatives; 00615 00616 mutable TQDict<TQStringList> dircache; 00617 mutable TQDict<TQString> savelocations; 00618 00619 // Disallow assignment and copy-construction 00620 TDEStandardDirs( const TDEStandardDirs& ); 00621 TDEStandardDirs& operator= ( const TDEStandardDirs& ); 00622 00623 bool addedCustoms; 00624 00625 class TDEStandardDirsPrivate; 00626 TDEStandardDirsPrivate *d; 00627 00628 void checkConfig() const; 00629 void applyDataRestrictions(const TQString &) const; 00630 void createSpecialResource(const char*); 00631 00632 // Like their public counter parts but with an extra priority argument 00633 // If priority is true, the directory is added directly after 00634 // $TDEHOME/$XDG_DATA_HOME/$XDG_CONFIG_HOME 00635 void addPrefix( const TQString& dir, bool priority ); 00636 void addXdgConfigPrefix( const TQString& dir, bool priority ); 00637 void addXdgDataPrefix( const TQString& dir, bool priority ); 00638 00639 // If priority is true, the directory is added before any other, 00640 // otherwise after 00641 bool addResourceType( const char *type, 00642 const TQString& relativename, bool priority ); 00643 bool addResourceDir( const char *type, 00644 const TQString& absdir, bool priority); 00645 }; 00646 00703 TDECORE_EXPORT TQString locate( const char *type, const TQString& filename, const TDEInstance* instance = TDEGlobal::instance() ); 00704 00714 TDECORE_EXPORT TQString locateLocal( const char *type, const TQString& filename, const TDEInstance* instance = TDEGlobal::instance() ); 00715 00725 TDECORE_EXPORT TQString locateLocal( const char *type, const TQString& filename, bool createDir, const TDEInstance* instance = TDEGlobal::instance() ); 00726 00729 #endif // SSK_KSTDDIRS_H