archive_sdmc.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <algorithm>
  5. #include "common/file_util.h"
  6. #include "common/logging/log.h"
  7. #include "common/make_unique.h"
  8. #include "core/file_sys/archive_sdmc.h"
  9. #include "core/file_sys/disk_archive.h"
  10. #include "core/settings.h"
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. // FileSys namespace
  13. namespace FileSys {
  14. ArchiveFactory_SDMC::ArchiveFactory_SDMC(const std::string& sdmc_directory) : sdmc_directory(sdmc_directory) {
  15. LOG_INFO(Service_FS, "Directory %s set as SDMC.", sdmc_directory.c_str());
  16. }
  17. bool ArchiveFactory_SDMC::Initialize() {
  18. if (!Settings::values.use_virtual_sd) {
  19. LOG_WARNING(Service_FS, "SDMC disabled by config.");
  20. return false;
  21. }
  22. if (!FileUtil::CreateFullPath(sdmc_directory)) {
  23. LOG_ERROR(Service_FS, "Unable to create SDMC path.");
  24. return false;
  25. }
  26. return true;
  27. }
  28. ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SDMC::Open(const Path& path) {
  29. auto archive = Common::make_unique<DiskArchive>(sdmc_directory);
  30. return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
  31. }
  32. ResultCode ArchiveFactory_SDMC::Format(const Path& path) {
  33. // This is kind of an undesirable operation, so let's just ignore it. :)
  34. return RESULT_SUCCESS;
  35. }
  36. } // namespace FileSys