OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef TOOLS_GN_INPUT_FILE_H_ |
| 6 #define TOOLS_GN_INPUT_FILE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" |
| 13 #include "tools/gn/source_dir.h" |
| 14 #include "tools/gn/source_file.h" |
| 15 |
| 16 class InputFile { |
| 17 public: |
| 18 InputFile(const SourceFile& name); |
| 19 |
| 20 // Constructor for testing. Uses an empty file path and a given contents. |
| 21 //InputFile(const char* contents); |
| 22 ~InputFile(); |
| 23 |
| 24 const SourceFile& name() const { return name_; } |
| 25 |
| 26 // The directory is just a cached version of name_->GetDir() but we get this |
| 27 // a lot so computing it once up front saves a bunch of work. |
| 28 const SourceDir& dir() const { return dir_; } |
| 29 |
| 30 const std::string& contents() const { |
| 31 DCHECK(contents_loaded_); |
| 32 return contents_; |
| 33 } |
| 34 |
| 35 // For testing and in cases where this input doesn't actually refer to |
| 36 // "a file". |
| 37 void SetContents(const std::string& c); |
| 38 |
| 39 // Loads the given file synchronously, returning true on success. This |
| 40 bool Load(const base::FilePath& system_path); |
| 41 |
| 42 private: |
| 43 SourceFile name_; |
| 44 SourceDir dir_; |
| 45 |
| 46 bool contents_loaded_; |
| 47 std::string contents_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(InputFile); |
| 50 }; |
| 51 |
| 52 #endif // TOOLS_GN_INPUT_FILE_H_ |
OLD | NEW |