raw_filesystem.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // Copyright (C) 2015 The Android Open Source Project
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include "update_engine/payload_generator/raw_filesystem.h"
  17. #include <memory>
  18. #include "update_engine/common/utils.h"
  19. #include "update_engine/payload_generator/extent_ranges.h"
  20. #include "update_engine/update_metadata.pb.h"
  21. using std::unique_ptr;
  22. namespace chromeos_update_engine {
  23. unique_ptr<RawFilesystem> RawFilesystem::Create(const std::string& filename,
  24. uint64_t block_size,
  25. uint64_t block_count) {
  26. unique_ptr<RawFilesystem> result(new RawFilesystem());
  27. result->filename_ = filename;
  28. result->block_size_ = block_size;
  29. result->block_count_ = block_count;
  30. return result;
  31. }
  32. size_t RawFilesystem::GetBlockSize() const {
  33. return block_size_;
  34. }
  35. size_t RawFilesystem::GetBlockCount() const {
  36. return block_count_;
  37. }
  38. bool RawFilesystem::GetFiles(std::vector<File>* files) const {
  39. files->clear();
  40. File file;
  41. file.name = filename_;
  42. file.extents = {ExtentForRange(0, block_count_)};
  43. files->push_back(file);
  44. return true;
  45. }
  46. } // namespace chromeos_update_engine