1 // Copyright 2015 Google Inc. All rights reserved
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef FILEUTIL_H_
16 #define FILEUTIL_H_
17 
18 #include <memory>
19 #include <string>
20 #include <unordered_map>
21 #include <vector>
22 
23 #include "string_piece.h"
24 
25 using namespace std;
26 
27 bool Exists(StringPiece f);
28 double GetTimestampFromStat(const struct stat& st);
29 double GetTimestamp(StringPiece f);
30 
31 enum struct RedirectStderr {
32   NONE,
33   STDOUT,
34   DEV_NULL,
35 };
36 
37 int RunCommand(const string& shell, const string& cmd,
38                RedirectStderr redirect_stderr,
39                string* out);
40 
41 void GetExecutablePath(string* path);
42 
43 void Glob(const char* pat, vector<string>** files);
44 
45 const unordered_map<string, vector<string>*>& GetAllGlobCache();
46 
47 void ClearGlobCache();
48 
49 #endif  // FILEUTIL_H_
50