-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdir_util.h
More file actions
24 lines (20 loc) · 1.03 KB
/
dir_util.h
File metadata and controls
24 lines (20 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <string>
#include <vector>
#include <map>
namespace DirUtil {
bool Ls(const char* directory, std::vector<std::string>* result, size_t* count, const mode_t* mode = NULL, bool fill_path = false);
bool LsDir(const char* directory, std::vector<std::string>& dirs, bool fill_path = false);
bool LsFile(const char* directory, std::vector<std::string>& files, bool fill_path = false);
bool DirCount(const char* directory, size_t& count);
bool FileCount(const char* directory, size_t& count);
std::string Pwd();
// linux only cause 'inode'
typedef std::map<ino_t, std::string> OrderedResult_t;
bool LsOrdered(const char* directory, OrderedResult_t* result, size_t* count, const mode_t* mode = NULL, bool fill_path = false);
bool LsDirOrdered(const char* directory, OrderedResult_t& dirs, bool fill_path = false);
bool LsFileOrdered(const char* directory, OrderedResult_t& files, bool fill_path = false);
} // namespace DirUtil