From 347e98dcd2d29772d5b9cf23c307b0a6ce0d8858 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 14 Apr 2015 15:32:05 -0700 Subject: Just return files from listDirectory() since that is all we need, fix network request on network restore logic, and remember saved networks in service/One --- osdep/OSUtils.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'osdep/OSUtils.cpp') diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp index 1fa2f8b0..60e6d6ba 100644 --- a/osdep/OSUtils.cpp +++ b/osdep/OSUtils.cpp @@ -75,38 +75,35 @@ bool OSUtils::redirectUnixOutputs(const char *stdoutPath,const char *stderrPath) } #endif // __UNIX_LIKE__ -std::map OSUtils::listDirectory(const char *path) +std::vector OSUtils::listDirectory(const char *path) { - std::map r; + std::vector r; #ifdef __WINDOWS__ HANDLE hFind; WIN32_FIND_DATAA ffd; if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) { do { - if ((strcmp(ffd.cFileName,"."))&&(strcmp(ffd.cFileName,".."))) - r[std::string(ffd.cFileName)] = ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); + if ((strcmp(ffd.cFileName,"."))&&(strcmp(ffd.cFileName,".."))&&((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)) + r.push_back(std::string(ffd.cFileName)); } while (FindNextFileA(hFind,&ffd)); FindClose(hFind); } #else struct dirent de; struct dirent *dptr; - DIR *d = opendir(path); if (!d) return r; - dptr = (struct dirent *)0; for(;;) { if (readdir_r(d,&de,&dptr)) break; if (dptr) { - if ((strcmp(dptr->d_name,"."))&&(strcmp(dptr->d_name,".."))) - r[std::string(dptr->d_name)] = (dptr->d_type == DT_DIR); + if ((strcmp(dptr->d_name,"."))&&(strcmp(dptr->d_name,".."))&&(dptr->d_type != DT_DIR)) + r.push_back(std::string(dptr->d_name)); } else break; } - closedir(d); #endif -- cgit v1.2.3