lakshmana | e140917 | 2018-02-22 15:09:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef PERFTOOLS_PERF_TO_PROFILE_LIB_H_ |
| 9 | #define PERFTOOLS_PERF_TO_PROFILE_LIB_H_ |
| 10 | |
| 11 | #include <unistd.h> |
| 12 | #include <fstream> |
| 13 | |
| 14 | #include "base/logging.h" |
| 15 | #include "string_compat.h" |
| 16 | |
| 17 | // Checks and returns whether or not the file at the given |path| already |
| 18 | // exists. |
| 19 | bool FileExists(const string& path); |
| 20 | |
| 21 | // Reads a file at the given |path| as a string and returns it. |
| 22 | string ReadFileToString(const string& path); |
| 23 | |
| 24 | // Creates a file at the given |path|. If |overwriteOutput| is set to true, |
| 25 | // overwrites the file at the given path. |
| 26 | void CreateFile(const string& path, std::ofstream* file, bool overwriteOutput); |
| 27 | |
| 28 | // Parses arguments, stores the results in |input|, |output| and |
| 29 | // |overwriteOutput|, and returns true if arguments parsed successfully and |
| 30 | // false otherwise. |
| 31 | bool ParseArguments(int argc, const char* argv[], string* input, string* output, |
| 32 | bool* overwriteOutput); |
| 33 | |
| 34 | // Prints the usage of the tool. |
| 35 | void PrintUsage(); |
| 36 | |
| 37 | #endif // PERFTOOLS_PERF_TO_PROFILE_LIB_H_ |