forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalFileResult.h
64 lines (55 loc) · 2.3 KB
/
LocalFileResult.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include "thirdparty/jansson/jansson.h"
#include "watchman.h"
#include "watchman_query.h"
#include "watchman_string.h"
namespace watchman {
/** A FileResult that exists on the local filesystem.
* This differs from InMemoryFileResult in that we don't maintain any
* long-lived persistent information about the file and that the methods of
* this instance will query the local filesystem to discover the information as
* it is accessed.
* We do cache the results of any filesystem operations that we may perform
* for the duration of the lifetime of a given LocalFileResult, but that
* information is not shared beyond that lifetime.
* FileResult objects are typically extremely short lived, existing between
* the point in time at which a file is matched by a query and the time
* at which the file is rendered into the results of the query.
*/
class LocalFileResult : public FileResult {
public:
LocalFileResult(
const std::shared_ptr<w_root_t>& root_,
w_string_piece path,
w_clock_t clock);
// Returns stat-like information about this file. If the file doesn't
// exist the stat information will be largely useless (it will be zeroed
// out), but will report itself as being a regular file. This is fine
// today because the only source of LocalFileResult instances today is
// based on the list of files returned from source control, and scm
// of today only reports files, never dirs.
const watchman::FileInformation& stat() const override;
// Returns the name of the file in its containing dir
w_string_piece baseName() const override;
// Returns the name of the containing dir relative to the
// VFS root
w_string_piece dirName() override;
// Returns true if the file currently exists
bool exists() const override;
// Returns the symlink target
watchman::Future<w_string> readLink() override;
const w_clock_t& ctime() const override;
const w_clock_t& otime() const override;
// Returns the SHA-1 hash of the file contents
watchman::Future<FileResult::ContentHash> getContentSha1() override;
private:
void getInfo() const;
w_string getFullPath() const;
mutable bool needInfo_{true};
mutable bool exists_{true};
mutable FileInformation info_;
std::shared_ptr<w_root_t> root_;
w_string fullPath_;
w_clock_t clock_;
};
} // namespace watchman