mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 23:10:37 +02:00
In FileLister::browse, declare variables when they are needed
This commit is contained in:
parent
2c76ddae50
commit
90a5f82b92
@ -83,27 +83,24 @@ void FileLister::browse(const string& path, bool clean)
|
|||||||
directories.clear();
|
directories.clear();
|
||||||
files.clear();
|
files.clear();
|
||||||
|
|
||||||
DIR *dirp;
|
|
||||||
string slashedPath = path;
|
string slashedPath = path;
|
||||||
if (path[path.length() - 1] != '/')
|
if (path[path.length() - 1] != '/')
|
||||||
slashedPath.push_back('/');
|
slashedPath.push_back('/');
|
||||||
|
|
||||||
|
DIR *dirp;
|
||||||
if ((dirp = opendir(slashedPath.c_str())) == NULL) {
|
if ((dirp = opendir(slashedPath.c_str())) == NULL) {
|
||||||
ERROR("Unable to open directory: %s\n", slashedPath.c_str());
|
ERROR("Unable to open directory: %s\n", slashedPath.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string filepath, file;
|
while (struct dirent *dptr = readdir(dirp)) {
|
||||||
struct stat st;
|
string file = dptr->d_name;
|
||||||
struct dirent *dptr;
|
|
||||||
|
|
||||||
while ((dptr = readdir(dirp))) {
|
|
||||||
file = dptr->d_name;
|
|
||||||
|
|
||||||
if (file[0] == '.' && file != "..")
|
if (file[0] == '.' && file != "..")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
filepath = slashedPath + file;
|
string filepath = slashedPath + file;
|
||||||
|
struct stat st;
|
||||||
int statRet = stat(filepath.c_str(), &st);
|
int statRet = stat(filepath.c_str(), &st);
|
||||||
if (statRet == -1) {
|
if (statRet == -1) {
|
||||||
ERROR("Stat failed on '%s' with error '%s'\n", filepath.c_str(), strerror(errno));
|
ERROR("Stat failed on '%s' with error '%s'\n", filepath.c_str(), strerror(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user