36 #include <sys/types.h>
41 #include "YSettings.h"
42 #include "Libyui_config.h"
44 #define YUILogComponent "ui"
55 bool isThemeDir = ! directory.compare ( THEMEDIR );
58 string themeSubDir =
"/current";
59 size_t splitPos = fullPath.rfind(
"/" );
60 bool hasProgSubDir = progSubDir.compare (
"" );
61 bool hasSubDirPrepend = ( splitPos != string::npos );
62 string filenameNoPrepend = filename.substr ( splitPos + 1, string::npos );
63 string subDirPrepend =
"";
64 vector<string> dirList;
66 if ( hasSubDirPrepend )
67 subDirPrepend = filename.substr ( 0, splitPos );
73 if ( hasSubDirPrepend )
78 dirList.push_back( directory +
"/" + progSubDir + themeSubDir +
"/" + subDirPrepend );
80 dirList.push_back( directory + themeSubDir +
"/" + subDirPrepend );
83 dirList.push_back( directory +
"/" + progSubDir +
"/" + subDirPrepend );
85 dirList.push_back( directory +
"/" + subDirPrepend );
91 dirList.push_back( directory +
"/" + progSubDir + themeSubDir );
93 dirList.push_back( directory + themeSubDir );
98 dirList.push_back( directory +
"/" + progSubDir );
100 dirList.push_back ( directory );
102 for ( vector<string>::const_iterator x = dirList.begin ();
103 x != dirList.end () && fullPath.compare (
"" ) == 0 ;
106 vector<string> fileList = lsDir( *x );
108 for ( vector<string>::const_iterator i = fileList.begin ();
109 i != fileList.end () && fullPath.compare (
"" ) == 0 ;
112 if ( *i !=
"." && *i !=
".." )
114 fullname = directory +
"/" + *i;
115 if ( *i == filenameNoPrepend )
119 fullPath = lookRecursive ( fullname, filenameNoPrepend );
125 if ( fullPath.compare(
"" ) != 0 )
142 vector<string> YPath::lsDir(
const string & directory )
144 vector<string> fileList;
148 if ( (
dir = opendir( directory.c_str () ) ) != NULL )
152 while ( ( ent = readdir(
dir ) ) != NULL )
153 fileList.push_back( ent -> d_name );
162 string YPath::lookRecursive(
const string & directory,
const string & filename )
164 vector<string> fileList = lsDir( directory );
168 for ( vector<string>::const_iterator i = fileList.begin();
169 i != fileList.end() && file.compare (
"" ) == 0;
172 if ( *i !=
"." && *i !=
".." )
174 fullname = directory +
"/" + ( *i );
176 if ( *i == filename )
180 file = lookRecursive ( fullname, filename );
197 return fullPath.substr ( 0, fullPath.rfind(
"/" ) );