libsaria: Use lstat for listing directories
Now I work on JFS in addition to other filesystems... Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
c3bb6119e5
commit
574e1062fa
|
@ -9,11 +9,6 @@
|
|||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
/* I want to use the d_type field in a dirent */
|
||||
#ifndef __USE_BSD
|
||||
#define __USE_BSD
|
||||
#endif
|
||||
|
||||
static string appdir;
|
||||
static mode_t dirmode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
|
||||
|
@ -25,18 +20,19 @@ static void make_dir(string path)
|
|||
|
||||
static void handle_entry(string &dir, list<string> &file_list, struct dirent *dirp)
|
||||
{
|
||||
struct stat stat;
|
||||
|
||||
string name = dirp->d_name;
|
||||
if (name == "." || name == "..")
|
||||
return;
|
||||
name = dir + "/" + name;
|
||||
|
||||
switch(dirp->d_type) {
|
||||
case DT_DIR:
|
||||
libsaria::list_dir(name, file_list);
|
||||
break;
|
||||
default:
|
||||
file_list.push_back(name);
|
||||
};
|
||||
if (lstat(name.c_str(), &stat) == 0) {
|
||||
if (S_ISDIR(stat.st_mode))
|
||||
libsaria::list_dir(name, file_list);
|
||||
else
|
||||
file_list.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
static bool compare_files(string &one, string &two)
|
||||
|
|
Loading…
Reference in New Issue