libyui
3.0.10
|
00001 /* 00002 Copyright (c) 2012 Björn Esser 00003 00004 Permission is hereby granted, free of charge, to any person obtaining 00005 a copy of this software and associated documentation files (the 00006 "Software"), to deal in the Software without restriction, including 00007 without limitation the rights to use, copy, modify, merge, publish, 00008 distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be 00013 included in all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 00018 SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00019 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 00020 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 00021 THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00022 */ 00023 00024 00025 /*-/ 00026 00027 File: YPath.h 00028 00029 Author: Björn Esser <bjoern.esser@gmail.com> 00030 00031 /-*/ 00032 00033 #ifndef YPath_h 00034 #define YPath_h 00035 00036 #include <string> 00037 #include <vector> 00038 00039 /** 00040 * Finds files (e.g. plugins or theme pixmaps) recursively inside 00041 * a directory. 00042 **/ 00043 class YPath 00044 { 00045 00046 public: 00047 00048 /** 00049 * Constructor 00050 * 00051 * to be called with the directory where to look inside 00052 * and filename which to lookup. 00053 * 00054 * YSettings::progSubDir will be preferred by the lookup. 00055 **/ 00056 YPath( const std::string & directory, const std::string & filename ); 00057 /** 00058 * Destructor 00059 **/ 00060 ~YPath(); 00061 /** 00062 * Returns the full path of the file if found; 00063 * if not found just the filename given in constructor. 00064 **/ 00065 std::string path(); 00066 /** 00067 * Returns the directory where the file is found; 00068 * if not found just the subdir part (if there's any) of 00069 * the filename given in constructor. 00070 **/ 00071 std::string dir(); 00072 00073 private: 00074 00075 std::vector<std::string> lsDir( const std::string & directory ); 00076 std::string lookRecursive( const std::string & directory, const std::string & filename ); 00077 std::string fullPath; 00078 00079 }; 00080 00081 #endif // YUIDIRFINDER_H