ivfc_archive.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <memory>
  5. #include "common/common_types.h"
  6. #include "common/file_util.h"
  7. #include "common/logging/log.h"
  8. #include "common/make_unique.h"
  9. #include "core/file_sys/ivfc_archive.h"
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////
  11. // FileSys namespace
  12. namespace FileSys {
  13. IVFCArchive::IVFCArchive(std::shared_ptr<const std::vector<u8>> data) : data(data) {
  14. }
  15. std::string IVFCArchive::GetName() const {
  16. return "IVFC";
  17. }
  18. std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const {
  19. return Common::make_unique<IVFCFile>(data);
  20. }
  21. bool IVFCArchive::DeleteFile(const Path& path) const {
  22. LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", GetName().c_str());
  23. return false;
  24. }
  25. bool IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
  26. LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", GetName().c_str());
  27. return false;
  28. }
  29. bool IVFCArchive::DeleteDirectory(const Path& path) const {
  30. LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).", GetName().c_str());
  31. return false;
  32. }
  33. ResultCode IVFCArchive::CreateFile(const Path& path, u32 size) const {
  34. LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).", GetName().c_str());
  35. // TODO: Verify error code
  36. return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, ErrorLevel::Permanent);
  37. }
  38. bool IVFCArchive::CreateDirectory(const Path& path) const {
  39. LOG_CRITICAL(Service_FS, "Attempted to create a directory in an IVFC archive (%s).", GetName().c_str());
  40. return false;
  41. }
  42. bool IVFCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
  43. LOG_CRITICAL(Service_FS, "Attempted to rename a file within an IVFC archive (%s).", GetName().c_str());
  44. return false;
  45. }
  46. std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) const {
  47. return Common::make_unique<IVFCDirectory>();
  48. }
  49. ////////////////////////////////////////////////////////////////////////////////////////////////////
  50. size_t IVFCFile::Read(const u64 offset, const u32 length, u8* buffer) const {
  51. LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
  52. memcpy(buffer, data->data() + offset, length);
  53. return length;
  54. }
  55. size_t IVFCFile::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
  56. LOG_ERROR(Service_FS, "Attempted to write to IVFC file");
  57. return 0;
  58. }
  59. size_t IVFCFile::GetSize() const {
  60. return sizeof(u8) * data->size();
  61. }
  62. bool IVFCFile::SetSize(const u64 size) const {
  63. LOG_ERROR(Service_FS, "Attempted to set the size of an IVFC file");
  64. return false;
  65. }
  66. } // namespace FileSys