30 #include <sys/types.h>
31 #include <sys/param.h>
47 bool sortCallback(
const std::string & a,
const std::string & b)
52 int sortCallback(
const struct dirent ** a,
const struct dirent ** b)
108 std::string lastName;
109 bool endOfDir =
false;
122 WIN32_FIND_DATA fileInformation;
124 wchar_t * pathAll = createWCharFromChar((
path_+
"\\*").
c_str());
125 HANDLE hFile = ::FindFirstFile(pathAll, &fileInformation);
128 HANDLE hFile = ::FindFirstFile((
path_+
"\\*").
c_str(), &fileInformation);
130 if(hFile != INVALID_HANDLE_VALUE)
135 char * fileName = createCharFromWChar(fileInformation.cFileName);
139 fileNames_.push_back(fileInformation.cFileName);
141 }
while(::FindNextFile(hFile, &fileInformation) ==
TRUE);
144 std::sort(vFileNames.begin(), vFileNames.end(),
sortCallback);
149 struct dirent ** nameList = 0;
151 if(nameList && nameListSize>0)
153 for (
int i=0;
i<nameListSize;++
i)
169 iter->compare(
".") != 0 &&
170 iter->compare(
"..") != 0)
192 if(!lastName.empty())
197 if(lastName.compare(*
iter) == 0)
204 if(endOfDir && found)
223 std::string fileName;
234 std::string filePath;
254 wchar_t * wDirPath = createWCharFromChar(dirPath.c_str());
255 DWORD dwAttrib = GetFileAttributes(wDirPath);
258 DWORD dwAttrib = GetFileAttributes(dirPath.c_str());
260 r = (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
263 if((dp = opendir(dirPath.c_str())) !=
NULL)
275 std::string dir = filePath;
276 int i=(
int)dir.size()-1;
279 if(dir[
i] ==
'/' || dir[
i] ==
'\\')
284 while(
i>=0 && (dir[
i] ==
'/' || dir[
i] ==
'\\'))
324 if(trailingSeparator)
337 status = _mkdir(dirPath.c_str());
339 status = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
348 status = _rmdir(dirPath.c_str());
350 status = rmdir(dirPath.c_str());
360 wchar_t wProfilePath[250];
361 ExpandEnvironmentStrings(
L"%userprofile%",wProfilePath,250);
362 char * profilePath = createCharFromWChar(wProfilePath);
364 delete [] profilePath;
366 char profilePath[250];
367 ExpandEnvironmentStrings(
"%userprofile%",profilePath,250);
371 char * pathstr = getenv(
"HOME");
378 struct passwd *pw = getpwuid(getuid());
384 UFATAL(
"Environment variable HOME is not set, cannot get home directory! Please set HOME environment variable to a valid directory.");