blob: 5a4740d015b709cf04e667bf42e6f481d698668d [file] [log] [blame]
Shinichiro Hamaji1d545aa2015-06-23 15:29:13 +09001// 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
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090015#ifndef FILEUTIL_H_
16#define FILEUTIL_H_
17
Shinichiro Hamaji0e3873a2015-07-05 15:48:28 +090018#include <memory>
Shinichiro Hamaji94d6f2a2015-07-05 05:32:25 +090019#include <string>
Shinichiro Hamajia09ed282015-07-31 12:21:54 +090020#include <unordered_map>
Shinichiro Hamaji0e3873a2015-07-05 15:48:28 +090021#include <vector>
Shinichiro Hamaji94d6f2a2015-07-05 05:32:25 +090022
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090023#include "string_piece.h"
24
Shinichiro Hamaji94d6f2a2015-07-05 05:32:25 +090025using namespace std;
26
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090027bool Exists(StringPiece f);
Shinichiro Hamaji6ce977d2015-10-15 16:01:16 +090028double GetTimestampFromStat(const struct stat& st);
Shinichiro Hamajifda79432015-07-05 03:17:34 +090029double GetTimestamp(StringPiece f);
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090030
Shinichiro Hamajic9b0aca2015-07-31 16:47:56 +090031enum struct RedirectStderr {
32 NONE,
33 STDOUT,
34 DEV_NULL,
35};
36
37int RunCommand(const string& shell, const string& cmd,
38 RedirectStderr redirect_stderr,
Shinichiro Hamaji94d6f2a2015-07-05 05:32:25 +090039 string* out);
40
Shinichiro Hamajib58bb4b2015-07-30 18:02:51 +090041void GetExecutablePath(string* path);
42
Shinichiro Hamaji0e3873a2015-07-05 15:48:28 +090043void Glob(const char* pat, vector<string>** files);
44
Shinichiro Hamajia09ed282015-07-31 12:21:54 +090045const unordered_map<string, vector<string>*>& GetAllGlobCache();
46
47void ClearGlobCache();
48
Shinichiro Hamaji776ca302015-06-06 03:52:48 +090049#endif // FILEUTIL_H_