-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfs_utils.h
38 lines (34 loc) · 970 Bytes
/
fs_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <cstring>
#include <dirent.h>
#include <fcntl.h>
#include <iostream>
#include <limits>
#include <queue>
#include <string>
#include <sys/stat.h>
#include <unistd.h>
#include <unordered_map>
#include "trie.h"
constexpr int kMaxPathLength = 4096 / sizeof(char);
constexpr int kMaxComponentLength = 256 / sizeof(char);
using Stat = struct stat;
struct StatWrapper {
Stat stat;
bool is_invalid;
static StatWrapper FromStat(Stat);
static const StatWrapper invalid_stat;
};
struct FileSystemNode : public std::initializer_list<::FileSystemNode> {
std::string name_;
FileSystemNode(const std::string& path);
FileSystemNode();
operator std::string();
bool IsFile() const;
bool operator<(const FileSystemNode& other) const;
bool IsInvalid() const;
ino_t GetInode() const;
StatWrapper GetStat() const;
std::vector<FileSystemNode> GetEdges() const;
bool ContainsPattern(Trie& automaton) const;
};