Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame^] | 1 | // Copyright 2015 The Chromium OS 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 UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_ |
| 6 | #define UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_ |
| 7 | |
| 8 | // A fake filesystem interface implementation allowing the user to add arbitrary |
| 9 | // files/metadata. |
| 10 | |
| 11 | #include "update_engine/payload_generator/filesystem_interface.h" |
| 12 | |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
| 16 | #include "update_engine/update_metadata.pb.h" |
| 17 | |
| 18 | namespace chromeos_update_engine { |
| 19 | |
| 20 | class FakeFilesystem : public FilesystemInterface { |
| 21 | public: |
| 22 | FakeFilesystem(uint64_t block_size, uint64_t block_count); |
| 23 | virtual ~FakeFilesystem() = default; |
| 24 | |
| 25 | // FilesystemInterface overrides. |
| 26 | size_t GetBlockSize() const override; |
| 27 | size_t GetBlockCount() const override; |
| 28 | bool GetFiles(std::vector<File>* files) const override; |
| 29 | |
| 30 | // Fake methods. |
| 31 | |
| 32 | // Add a file to the list of fake files. |
| 33 | void AddFile(const std::string& filename, const std::vector<Extent> extents); |
| 34 | |
| 35 | private: |
| 36 | FakeFilesystem() = default; |
| 37 | |
| 38 | uint64_t block_size_; |
| 39 | uint64_t block_count_; |
| 40 | |
| 41 | std::vector<File> files_; |
| 42 | |
| 43 | DISALLOW_COPY_AND_ASSIGN(FakeFilesystem); |
| 44 | }; |
| 45 | |
| 46 | } // namespace chromeos_update_engine |
| 47 | |
| 48 | #endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_ |