示例#1
0
文件: archive.cpp 项目: Glought/citra
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return ERR_INVALID_HANDLE;

    return archive->CreateFile(path, file_size);
}
示例#2
0
ResultCode ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
                                                          const FileSys::Path& src_path,
                                                          ArchiveHandle dest_archive_handle,
                                                          const FileSys::Path& dest_path) {
    ArchiveBackend* src_archive = GetArchive(src_archive_handle);
    ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
    if (src_archive == nullptr || dest_archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;

    if (src_archive == dest_archive) {
        return src_archive->RenameDirectory(src_path, dest_path);
    } else {
        // TODO: Implement renaming across archives
        return UnimplementedFunction(ErrorModule::FS);
    }
}
示例#3
0
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) {
    Archive* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return InvalidHandle(ErrorModule::FS);

    return archive->backend->CreateFile(path, file_size);
}
示例#4
0
ResultCode ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle,
                                                 const FileSys::Path& path) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;

    return archive->DeleteFile(path);
}
示例#5
0
ResultCode ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle,
                                               const FileSys::Path& path, u64 file_size) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;

    return archive->CreateFile(path, file_size);
}
示例#6
0
文件: archive.cpp 项目: Glought/citra
ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return ERR_INVALID_HANDLE;

    if (archive->CreateDirectory(path))
        return RESULT_SUCCESS;
    return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
                      ErrorSummary::Canceled, ErrorLevel::Status);
}
示例#7
0
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
    Archive* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return InvalidHandle(ErrorModule::FS);

    if (archive->backend->DeleteDirectory(path))
        return RESULT_SUCCESS;
    return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
                      ErrorSummary::Canceled, ErrorLevel::Status);
}
示例#8
0
文件: archive.cpp 项目: Glought/citra
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, const FileSys::Path& src_path,
                                          ArchiveHandle dest_archive_handle, const FileSys::Path& dest_path) {
    ArchiveBackend* src_archive = GetArchive(src_archive_handle);
    ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
    if (src_archive == nullptr || dest_archive == nullptr)
        return ERR_INVALID_HANDLE;

    if (src_archive == dest_archive) {
        if (src_archive->RenameDirectory(src_path, dest_path))
            return RESULT_SUCCESS;
    } else {
        // TODO: Implement renaming across archives
        return UnimplementedFunction(ErrorModule::FS);
    }

    // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
    // exist or similar. Verify.
    return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
                      ErrorSummary::NothingHappened, ErrorLevel::Status);
}
示例#9
0
unique_ptr<AsyncByteStream> ManifestItem::AsyncReader() const
{
    auto package = GetPackage();
    if ( !package )
        return nullptr;
    
    auto container = package->GetContainer();
    if ( !container )
        return nullptr;
    
    return container->GetArchive()->AsyncByteStreamAtPath(AbsolutePath());
}
示例#10
0
ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
    ArchiveHandle archive_handle, const FileSys::Path& path) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;

    auto backend = archive->OpenDirectory(path);
    if (backend.Failed())
        return backend.Code();

    auto directory = std::shared_ptr<Directory>(new Directory(std::move(backend).Unwrap(), path));
    return MakeResult<std::shared_ptr<Directory>>(std::move(directory));
}
示例#11
0
文件: archive.cpp 项目: Glought/citra
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
        const FileSys::Path& path) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return ERR_INVALID_HANDLE;

    std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path);
    if (backend == nullptr) {
        return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
                          ErrorSummary::NotFound, ErrorLevel::Permanent);
    }

    auto directory = Kernel::SharedPtr<Directory>(new Directory(std::move(backend), path));
    return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory));
}
示例#12
0
文件: archive.cpp 项目: Glought/citra
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
        const FileSys::Path& path, const FileSys::Mode mode) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return ERR_INVALID_HANDLE;

    std::unique_ptr<FileSys::FileBackend> backend = archive->OpenFile(path, mode);
    if (backend == nullptr) {
        return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS,
                          ErrorSummary::NotFound, ErrorLevel::Status);
    }

    auto file = Kernel::SharedPtr<File>(new File(std::move(backend), path));
    return MakeResult<Kernel::SharedPtr<File>>(std::move(file));
}
示例#13
0
std::tuple<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds>
ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
                                    const FileSys::Mode mode) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return std::make_tuple(FileSys::ERR_INVALID_ARCHIVE_HANDLE,
                               static_cast<std::chrono::nanoseconds>(0));

    std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()};
    auto backend = archive->OpenFile(path, mode);
    if (backend.Failed())
        return std::make_tuple(backend.Code(), open_timeout_ns);

    auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path));
    return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
}
示例#14
0
/**
 * Open a Directory from an Archive
 * @param archive_handle Handle to an open Archive object
 * @param path Path to the Directory inside of the Archive
 * @return Opened Directory object
 */
ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
    Archive* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return InvalidHandle(ErrorModule::FS);

    std::unique_ptr<FileSys::DirectoryBackend> backend = archive->backend->OpenDirectory(path);
    if (backend == nullptr) {
        return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
                          ErrorSummary::NotFound, ErrorLevel::Permanent);
    }

    auto directory = Common::make_unique<Directory>(std::move(backend), path);
    // TOOD(yuriks): Fix error reporting
    Handle handle = Kernel::g_handle_table.Create(directory.release()).ValueOr(INVALID_HANDLE);
    return MakeResult<Handle>(handle);
}
示例#15
0
ResultVal<u64> ArchiveManager::GetFreeBytesInArchive(ArchiveHandle archive_handle) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
    return MakeResult<u64>(archive->GetFreeBytes());
}