1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 07:13:20 +02:00

In FileLister::browse, declare variables when they are needed

This commit is contained in:
Maarten ter Huurne 2014-08-13 07:14:30 +02:00
parent 2c76ddae50
commit 90a5f82b92

View File

@ -83,27 +83,24 @@ void FileLister::browse(const string& path, bool clean)
directories.clear();
files.clear();
DIR *dirp;
string slashedPath = path;
if (path[path.length() - 1] != '/')
slashedPath.push_back('/');
DIR *dirp;
if ((dirp = opendir(slashedPath.c_str())) == NULL) {
ERROR("Unable to open directory: %s\n", slashedPath.c_str());
return;
}
string filepath, file;
struct stat st;
struct dirent *dptr;
while ((dptr = readdir(dirp))) {
file = dptr->d_name;
while (struct dirent *dptr = readdir(dirp)) {
string file = dptr->d_name;
if (file[0] == '.' && file != "..")
continue;
filepath = slashedPath + file;
string filepath = slashedPath + file;
struct stat st;
int statRet = stat(filepath.c_str(), &st);
if (statRet == -1) {
ERROR("Stat failed on '%s' with error '%s'\n", filepath.c_str(), strerror(errno));