libyui  3.3.2
YPath.h
1 /*
2  Copyright (c) 2012 Björn Esser
3 
4  Permission is hereby granted, free of charge, to any person obtaining
5  a copy of this software and associated documentation files (the
6  "Software"), to deal in the Software without restriction, including
7  without limitation the rights to use, copy, modify, merge, publish,
8  distribute, sublicense, and/or sell
9  copies of the Software, and to permit persons to whom the Software is
10  furnished to do so, subject to the following conditions:
11 
12  The above copyright notice and this permission notice shall be
13  included in all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18  SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 
25 /*-/
26 
27  File: YPath.h
28 
29  Author: Björn Esser <bjoern.esser@gmail.com>
30 
31 /-*/
32 
33 #ifndef YPath_h
34 #define YPath_h
35 
36 #include <string>
37 #include <vector>
38 
39 /**
40  * Finds files (e.g. plugins or theme pixmaps) recursively inside
41  * a directory.
42  **/
43 class YPath
44 {
45 
46 public:
47 
48 /**
49  * Constructor
50  *
51  * to be called with the directory where to look inside
52  * and filename which to lookup.
53  *
54  * YSettings::progSubDir will be preferred by the lookup.
55  **/
56  YPath( const std::string & directory, const std::string & filename );
57 /**
58  * Destructor
59  **/
60  ~YPath();
61 /**
62  * Returns the full path of the file if found;
63  * if not found just the filename given in constructor.
64  **/
65  std::string path();
66 /**
67  * Returns the directory where the file is found;
68  * if not found just the subdir part (if there's any) of
69  * the filename given in constructor.
70  **/
71  std::string dir();
72 
73 private:
74 
75  std::vector<std::string> lsDir( const std::string & directory );
76  std::string lookRecursive( const std::string & directory, const std::string & filename );
77  std::string fullPath;
78 
79 };
80 
81 #endif // YUIDIRFINDER_H
std::string path()
Returns the full path of the file if found; if not found just the filename given in constructor...
Definition: YPath.cc:171
~YPath()
Destructor.
Definition: YPath.cc:126
std::string dir()
Returns the directory where the file is found; if not found just the subdir part (if there&#39;s any) of ...
Definition: YPath.cc:176
YPath(const std::string &directory, const std::string &filename)
Constructor.
Definition: YPath.cc:47
Finds files (e.g.
Definition: YPath.h:43