mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-22 03:22:39 +02:00
creport: use fs bindings
This commit is contained in:
parent
36154c9115
commit
7b0eca77bf
@ -33,6 +33,7 @@
|
|||||||
#include <stratosphere/fs/fs_mount.hpp>
|
#include <stratosphere/fs/fs_mount.hpp>
|
||||||
#include <stratosphere/fs/fs_path_tool.hpp>
|
#include <stratosphere/fs/fs_path_tool.hpp>
|
||||||
#include <stratosphere/fs/fs_path_utils.hpp>
|
#include <stratosphere/fs/fs_path_utils.hpp>
|
||||||
|
#include <stratosphere/fs/fs_filesystem_utils.hpp>
|
||||||
#include <stratosphere/fs/fs_romfs_filesystem.hpp>
|
#include <stratosphere/fs/fs_romfs_filesystem.hpp>
|
||||||
#include <stratosphere/fs/impl/fs_data.hpp>
|
#include <stratosphere/fs/impl/fs_data.hpp>
|
||||||
#include <stratosphere/fs/fs_system_data.hpp>
|
#include <stratosphere/fs/fs_system_data.hpp>
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
* version 2, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include "fs_common.hpp"
|
||||||
|
#include "fs_filesystem.hpp"
|
||||||
|
|
||||||
|
namespace ams::fs {
|
||||||
|
|
||||||
|
/* Common utilities. */
|
||||||
|
Result EnsureDirectoryRecursively(const char *path);
|
||||||
|
Result EnsureParentDirectoryRecursively(const char *path);
|
||||||
|
|
||||||
|
Result HasFile(bool *out, const char *path);
|
||||||
|
Result HasDirectory(bool *out, const char *path);
|
||||||
|
|
||||||
|
}
|
@ -142,7 +142,8 @@ namespace ams::fssystem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Other utility. */
|
/* Other utility. */
|
||||||
Result EnsureDirectoryExistsRecursively(fs::fsa::IFileSystem *fs, const char *path);
|
Result EnsureDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *path);
|
||||||
|
Result EnsureParentDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *path);
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
NX_INLINE Result RetryFinitelyForTargetLocked(F f) {
|
NX_INLINE Result RetryFinitelyForTargetLocked(F f) {
|
||||||
|
70
libstratosphere/source/fs/fs_filesystem_utils.cpp
Normal file
70
libstratosphere/source/fs/fs_filesystem_utils.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
* version 2, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
#include "fsa/fs_mount_utils.hpp"
|
||||||
|
#include "fsa/fs_filesystem_accessor.hpp"
|
||||||
|
|
||||||
|
namespace ams::fs {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
Result HasEntry(bool *out, const char *path, fs::DirectoryEntryType type) {
|
||||||
|
/* Set out to false initially. */
|
||||||
|
*out = false;
|
||||||
|
|
||||||
|
/* Try to get the entry type. */
|
||||||
|
fs::DirectoryEntryType entry_type;
|
||||||
|
R_TRY_CATCH(fs::GetEntryType(std::addressof(entry_type), path)) {
|
||||||
|
/* If the path doesn't exist, nothing has gone wrong. */
|
||||||
|
R_CONVERT(fs::ResultPathNotFound, ResultSuccess());
|
||||||
|
} R_END_TRY_CATCH;
|
||||||
|
|
||||||
|
/* We succeeded. */
|
||||||
|
*out = entry_type == type;
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Result EnsureDirectoryRecursively(const char *path) {
|
||||||
|
/* Get the filesystem accessor and sub path. */
|
||||||
|
impl::FileSystemAccessor *accessor;
|
||||||
|
const char *sub_path;
|
||||||
|
R_TRY(impl::FindFileSystem(std::addressof(accessor), std::addressof(sub_path), path));
|
||||||
|
|
||||||
|
/* Use the system implementation. */
|
||||||
|
return fssystem::EnsureDirectoryRecursively(accessor->GetRawFileSystemUnsafe(), sub_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result EnsureParentDirectoryRecursively(const char *path) {
|
||||||
|
/* Get the filesystem accessor and sub path. */
|
||||||
|
impl::FileSystemAccessor *accessor;
|
||||||
|
const char *sub_path;
|
||||||
|
R_TRY(impl::FindFileSystem(std::addressof(accessor), std::addressof(sub_path), path));
|
||||||
|
|
||||||
|
/* Use the system implementation. */
|
||||||
|
return fssystem::EnsureParentDirectoryRecursively(accessor->GetRawFileSystemUnsafe(), sub_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HasFile(bool *out, const char *path) {
|
||||||
|
return HasEntry(out, path, fs::DirectoryEntryType_File);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result HasDirectory(bool *out, const char *path) {
|
||||||
|
return HasEntry(out, path, fs::DirectoryEntryType_Directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -86,6 +86,10 @@ namespace ams::fs::impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<fssrv::impl::FileSystemInterfaceAdapter> GetMultiCommitTarget();
|
std::shared_ptr<fssrv::impl::FileSystemInterfaceAdapter> GetMultiCommitTarget();
|
||||||
|
|
||||||
|
fsa::IFileSystem *GetRawFileSystemUnsafe() {
|
||||||
|
return this->impl.get();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void NotifyCloseFile(FileAccessor *f);
|
void NotifyCloseFile(FileAccessor *f);
|
||||||
void NotifyCloseDirectory(DirectoryAccessor *d);
|
void NotifyCloseDirectory(DirectoryAccessor *d);
|
||||||
|
@ -19,7 +19,7 @@ namespace ams::fssystem {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
inline Result EnsureDirectoryExists(fs::fsa::IFileSystem *fs, const char *path) {
|
inline Result EnsureDirectory(fs::fsa::IFileSystem *fs, const char *path) {
|
||||||
R_TRY_CATCH(fs->CreateDirectory(path)) {
|
R_TRY_CATCH(fs->CreateDirectory(path)) {
|
||||||
R_CATCH(fs::ResultPathAlreadyExists) { /* If path already exists, there's no problem. */ }
|
R_CATCH(fs::ResultPathAlreadyExists) { /* If path already exists, there's no problem. */ }
|
||||||
} R_END_TRY_CATCH;
|
} R_END_TRY_CATCH;
|
||||||
@ -27,6 +27,30 @@ namespace ams::fssystem {
|
|||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result EnsureDirectoryRecursivelyImpl(fs::fsa::IFileSystem *fs, const char *path, bool create_last) {
|
||||||
|
/* Normalize the path. */
|
||||||
|
char normalized_path[fs::EntryNameLengthMax + 1];
|
||||||
|
size_t normalized_path_len;
|
||||||
|
R_TRY(PathTool::Normalize(normalized_path, &normalized_path_len, path, sizeof(normalized_path)));
|
||||||
|
|
||||||
|
/* Repeatedly call CreateDirectory on each directory leading to the target. */
|
||||||
|
for (size_t i = 1; i < normalized_path_len; i++) {
|
||||||
|
/* If we detect a separator, create the directory. */
|
||||||
|
if (PathTool::IsSeparator(normalized_path[i])) {
|
||||||
|
normalized_path[i] = StringTraits::NullTerminator;
|
||||||
|
R_TRY(EnsureDirectory(fs, normalized_path));
|
||||||
|
normalized_path[i] = StringTraits::DirectorySeparator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the last directory if requested. */
|
||||||
|
if (create_last) {
|
||||||
|
R_TRY(EnsureDirectory(fs, normalized_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) {
|
Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) {
|
||||||
@ -93,26 +117,12 @@ namespace ams::fssystem {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result EnsureDirectoryExistsRecursively(fs::fsa::IFileSystem *fs, const char *path) {
|
Result EnsureDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *path) {
|
||||||
/* Normalize the path. */
|
return EnsureDirectoryRecursivelyImpl(fs, path, true);
|
||||||
char normalized_path[fs::EntryNameLengthMax + 1];
|
|
||||||
size_t normalized_path_len;
|
|
||||||
R_TRY(PathTool::Normalize(normalized_path, &normalized_path_len, path, sizeof(normalized_path)));
|
|
||||||
|
|
||||||
/* Repeatedly call CreateDirectory on each directory leading to the target. */
|
|
||||||
for (size_t i = 1; i < normalized_path_len; i++) {
|
|
||||||
/* If we detect a separator, create the directory. */
|
|
||||||
if (PathTool::IsSeparator(normalized_path[i])) {
|
|
||||||
normalized_path[i] = StringTraits::NullTerminator;
|
|
||||||
R_TRY(EnsureDirectoryExists(fs, normalized_path));
|
|
||||||
normalized_path[i] = StringTraits::DirectorySeparator;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call CreateDirectory on the final path. */
|
Result EnsureParentDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *path) {
|
||||||
R_TRY(EnsureDirectoryExists(fs, normalized_path));
|
return EnsureDirectoryRecursivelyImpl(fs, path, false);
|
||||||
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ namespace ams::ncm {
|
|||||||
ON_SCOPE_EXIT { fs::Unmount(root->mount_name); };
|
ON_SCOPE_EXIT { fs::Unmount(root->mount_name); };
|
||||||
|
|
||||||
/* Ensure the path exists for us to import to. */
|
/* Ensure the path exists for us to import to. */
|
||||||
R_TRY(impl::EnsureDirectoryRecursively(root->path));
|
R_TRY(fs::EnsureDirectoryRecursively(root->path));
|
||||||
|
|
||||||
/* Copy the file from bis to our save. */
|
/* Copy the file from bis to our save. */
|
||||||
R_TRY(impl::CopyFile(savedata_db_path, bis_db_path));
|
R_TRY(impl::CopyFile(savedata_db_path, bis_db_path));
|
||||||
@ -389,7 +389,7 @@ namespace ams::ncm {
|
|||||||
ON_SCOPE_EXIT { fs::Unmount(root->mount_name); };
|
ON_SCOPE_EXIT { fs::Unmount(root->mount_name); };
|
||||||
|
|
||||||
/* Ensure the content storage root's path exists. */
|
/* Ensure the content storage root's path exists. */
|
||||||
R_TRY(impl::EnsureDirectoryRecursively(root->path));
|
R_TRY(fs::EnsureDirectoryRecursively(root->path));
|
||||||
|
|
||||||
/* Initialize content and placeholder directories for the root. */
|
/* Initialize content and placeholder directories for the root. */
|
||||||
return ContentStorageImpl::InitializeBase(root->path);
|
return ContentStorageImpl::InitializeBase(root->path);
|
||||||
@ -409,7 +409,7 @@ namespace ams::ncm {
|
|||||||
ON_SCOPE_EXIT { fs::Unmount(root->mount_name); };
|
ON_SCOPE_EXIT { fs::Unmount(root->mount_name); };
|
||||||
|
|
||||||
/* Ensure the content meta database root's path exists. */
|
/* Ensure the content meta database root's path exists. */
|
||||||
R_TRY(impl::EnsureDirectoryRecursively(root->path));
|
R_TRY(fs::EnsureDirectoryRecursively(root->path));
|
||||||
|
|
||||||
/* Commit our changes. */
|
/* Commit our changes. */
|
||||||
return fs::CommitSaveData(root->mount_name);
|
return fs::CommitSaveData(root->mount_name);
|
||||||
@ -454,7 +454,7 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Ensure the root path exists. */
|
/* Ensure the root path exists. */
|
||||||
bool has_dir = false;
|
bool has_dir = false;
|
||||||
R_TRY(impl::HasDirectory(&has_dir, root->path));
|
R_TRY(fs::HasDirectory(&has_dir, root->path));
|
||||||
R_UNLESS(has_dir, ncm::ResultInvalidContentMetaDatabase());
|
R_UNLESS(has_dir, ncm::ResultInvalidContentMetaDatabase());
|
||||||
|
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
|
@ -36,7 +36,7 @@ namespace ams::ncm {
|
|||||||
Result EnsureContentDirectory(ContentId id, MakeContentPathFunction func, const char *root_path) {
|
Result EnsureContentDirectory(ContentId id, MakeContentPathFunction func, const char *root_path) {
|
||||||
PathString path;
|
PathString path;
|
||||||
MakeContentPath(std::addressof(path), id, func, root_path);
|
MakeContentPath(std::addressof(path), id, func, root_path);
|
||||||
return impl::EnsureParentDirectoryRecursively(path);
|
return fs::EnsureParentDirectoryRecursively(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result DeleteContentFile(ContentId id, MakeContentPathFunction func, const char *root_path) {
|
Result DeleteContentFile(ContentId id, MakeContentPathFunction func, const char *root_path) {
|
||||||
@ -175,11 +175,11 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Create the content directory. */
|
/* Create the content directory. */
|
||||||
MakeBaseContentDirectoryPath(std::addressof(path), root_path);
|
MakeBaseContentDirectoryPath(std::addressof(path), root_path);
|
||||||
R_TRY(impl::EnsureDirectoryRecursively(path));
|
R_TRY(fs::EnsureDirectoryRecursively(path));
|
||||||
|
|
||||||
/* Create the placeholder directory. */
|
/* Create the placeholder directory. */
|
||||||
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path);
|
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path);
|
||||||
return impl::EnsureDirectoryRecursively(path);
|
return fs::EnsureDirectoryRecursively(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ContentStorageImpl::CleanupBase(const char *root_path) {
|
Result ContentStorageImpl::CleanupBase(const char *root_path) {
|
||||||
@ -199,18 +199,18 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Check if root directory exists. */
|
/* Check if root directory exists. */
|
||||||
bool has_dir;
|
bool has_dir;
|
||||||
R_TRY(impl::HasDirectory(std::addressof(has_dir), root_path));
|
R_TRY(fs::HasDirectory(std::addressof(has_dir), root_path));
|
||||||
R_UNLESS(has_dir, ncm::ResultContentStorageBaseNotFound());
|
R_UNLESS(has_dir, ncm::ResultContentStorageBaseNotFound());
|
||||||
|
|
||||||
/* Check if content directory exists. */
|
/* Check if content directory exists. */
|
||||||
bool has_registered;
|
bool has_registered;
|
||||||
MakeBaseContentDirectoryPath(std::addressof(path), root_path);
|
MakeBaseContentDirectoryPath(std::addressof(path), root_path);
|
||||||
R_TRY(impl::HasDirectory(std::addressof(has_registered), path));
|
R_TRY(fs::HasDirectory(std::addressof(has_registered), path));
|
||||||
|
|
||||||
/* Check if placeholder directory exists. */
|
/* Check if placeholder directory exists. */
|
||||||
bool has_placeholder;
|
bool has_placeholder;
|
||||||
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path);
|
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), root_path);
|
||||||
R_TRY(impl::HasDirectory(std::addressof(has_placeholder), path));
|
R_TRY(fs::HasDirectory(std::addressof(has_placeholder), path));
|
||||||
|
|
||||||
/* Convert findings to results. */
|
/* Convert findings to results. */
|
||||||
R_UNLESS(has_registered || has_placeholder, ncm::ResultContentStorageBaseNotFound());
|
R_UNLESS(has_registered || has_placeholder, ncm::ResultContentStorageBaseNotFound());
|
||||||
@ -287,7 +287,7 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Check if placeholder file exists. */
|
/* Check if placeholder file exists. */
|
||||||
bool has = false;
|
bool has = false;
|
||||||
R_TRY(impl::HasFile(&has, placeholder_path));
|
R_TRY(fs::HasFile(&has, placeholder_path));
|
||||||
out.SetValue(has);
|
out.SetValue(has);
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Check if the content file exists. */
|
/* Check if the content file exists. */
|
||||||
bool has = false;
|
bool has = false;
|
||||||
R_TRY(impl::HasFile(&has, content_path));
|
R_TRY(fs::HasFile(&has, content_path));
|
||||||
out.SetValue(has);
|
out.SetValue(has);
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
@ -20,78 +20,10 @@ namespace ams::ncm::impl {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Result EnsureDirectory(const char *path) {
|
|
||||||
/* Create the path, and allow it to already exist. */
|
|
||||||
R_TRY_CATCH(fs::CreateDirectory(path)) {
|
|
||||||
R_CONVERT(fs::ResultPathAlreadyExists, ResultSuccess())
|
|
||||||
} R_END_TRY_CATCH;
|
|
||||||
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result EnsureDirectoryRecursivelyImpl(const char *path, bool create_last) {
|
|
||||||
char work_buf[fs::EntryNameLengthMax];
|
|
||||||
|
|
||||||
/* Ensure the path is not too long. */
|
|
||||||
const size_t len = std::strlen(path);
|
|
||||||
R_UNLESS(len + 1 <= sizeof(work_buf), ResultAllocationFailed());
|
|
||||||
|
|
||||||
/* Copy in the path. */
|
|
||||||
std::strncpy(work_buf, path, sizeof(work_buf));
|
|
||||||
|
|
||||||
/* Create all but the last directory. */
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
if (i > 0 && fs::PathTool::IsSeparator(work_buf[i]) && !fs::PathTool::IsDriveSeparator(work_buf[i-1])) {
|
|
||||||
work_buf[i] = fs::StringTraits::NullTerminator;
|
|
||||||
R_TRY(EnsureDirectory(work_buf));
|
|
||||||
work_buf[i] = fs::StringTraits::DirectorySeparator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the last directory if requested. */
|
|
||||||
if (create_last) {
|
|
||||||
R_TRY(EnsureDirectory(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
Result HasEntry(bool *out, const char *path, fs::DirectoryEntryType type) {
|
|
||||||
/* Set out to false initially. */
|
|
||||||
*out = false;
|
|
||||||
|
|
||||||
/* Try to get the entry type. */
|
|
||||||
fs::DirectoryEntryType entry_type;
|
|
||||||
R_TRY_CATCH(fs::GetEntryType(std::addressof(entry_type), path)) {
|
|
||||||
/* If the path doesn't exist, nothing has gone wrong. */
|
|
||||||
R_CONVERT(fs::ResultPathNotFound, ResultSuccess());
|
|
||||||
} R_END_TRY_CATCH;
|
|
||||||
|
|
||||||
/* We succeeded. */
|
|
||||||
*out = entry_type == type;
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::atomic<u32> g_mount_name_count;
|
std::atomic<u32> g_mount_name_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result HasFile(bool *out, const char *path) {
|
|
||||||
return HasEntry(out, path, fs::DirectoryEntryType_File);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result HasDirectory(bool *out, const char *path) {
|
|
||||||
return HasEntry(out, path, fs::DirectoryEntryType_Directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result EnsureDirectoryRecursively(const char *path) {
|
|
||||||
return EnsureDirectoryRecursivelyImpl(path, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result EnsureParentDirectoryRecursively(const char *path) {
|
|
||||||
return EnsureDirectoryRecursivelyImpl(path, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PathView::HasPrefix(std::string_view prefix) const {
|
bool PathView::HasPrefix(std::string_view prefix) const {
|
||||||
return this->path.compare(0, prefix.length(), prefix) == 0;
|
return this->path.compare(0, prefix.length(), prefix) == 0;
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,6 @@
|
|||||||
|
|
||||||
namespace ams::ncm::impl {
|
namespace ams::ncm::impl {
|
||||||
|
|
||||||
Result HasFile(bool *out, const char *path);
|
|
||||||
Result HasDirectory(bool *out, const char *path);
|
|
||||||
|
|
||||||
Result EnsureDirectoryRecursively(const char *path);
|
|
||||||
Result EnsureParentDirectoryRecursively(const char *path);
|
|
||||||
|
|
||||||
Result CopyFile(const char *dst_path, const char *src_path);
|
Result CopyFile(const char *dst_path, const char *src_path);
|
||||||
|
|
||||||
class PathView {
|
class PathView {
|
||||||
|
@ -59,7 +59,7 @@ namespace ams::ncm {
|
|||||||
Result PlaceHolderAccessor::EnsurePlaceHolderDirectory(PlaceHolderId placeholder_id) {
|
Result PlaceHolderAccessor::EnsurePlaceHolderDirectory(PlaceHolderId placeholder_id) {
|
||||||
PathString path;
|
PathString path;
|
||||||
this->MakePath(std::addressof(path), placeholder_id);
|
this->MakePath(std::addressof(path), placeholder_id);
|
||||||
return impl::EnsureParentDirectoryRecursively(path);
|
return fs::EnsureParentDirectoryRecursively(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result PlaceHolderAccessor::GetPlaceHolderIdFromFileName(PlaceHolderId *out, const char *name) {
|
Result PlaceHolderAccessor::GetPlaceHolderIdFromFileName(PlaceHolderId *out, const char *name) {
|
||||||
|
@ -97,12 +97,12 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Check if the file exists. */
|
/* Check if the file exists. */
|
||||||
bool has;
|
bool has;
|
||||||
R_TRY(impl::HasFile(std::addressof(has), content_path));
|
R_TRY(fs::HasFile(std::addressof(has), content_path));
|
||||||
|
|
||||||
/* If the file is absent, make the path for game card content meta and check presence again. */
|
/* If the file is absent, make the path for game card content meta and check presence again. */
|
||||||
if (!has) {
|
if (!has) {
|
||||||
MakeGameCardContentMetaPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
|
MakeGameCardContentMetaPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
|
||||||
R_TRY(impl::HasFile(std::addressof(has), content_path));
|
R_TRY(fs::HasFile(std::addressof(has), content_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
out.SetValue(has);
|
out.SetValue(has);
|
||||||
@ -118,7 +118,7 @@ namespace ams::ncm {
|
|||||||
|
|
||||||
/* Check if the file exists. */
|
/* Check if the file exists. */
|
||||||
bool has_file;
|
bool has_file;
|
||||||
R_TRY(impl::HasFile(std::addressof(has_file), content_path));
|
R_TRY(fs::HasFile(std::addressof(has_file), content_path));
|
||||||
|
|
||||||
/* If the file is absent, make the path for regular content. */
|
/* If the file is absent, make the path for regular content. */
|
||||||
if (!has_file) {
|
if (!has_file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user