/*
* Copyright (c) 2019 Adubbz
*
* 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 .
*/
#pragma once
#include
#include
#include "lr_types.hpp"
#include "ncm_types.hpp"
namespace sts::ncm {
class IContentStorage : public IServiceObject {
protected:
char root_path[FS_MAX_PATH-1];
MakeContentPathFunc make_content_path_func;
bool disabled;
public:
virtual Result GeneratePlaceHolderId(Out out);
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size);
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id);
virtual Result HasPlaceHolder(Out out, PlaceHolderId placeholder_id);
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, u64 offset, InBuffer data);
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id);
virtual Result Delete(ContentId content_id);
virtual Result Has(Out out, ContentId content_id);
virtual Result GetPath(OutPointerWithServerSize out, ContentId content_id);
virtual Result GetPlaceHolderPath(OutPointerWithServerSize out, PlaceHolderId placeholder_id);
virtual Result CleanupAllPlaceHolder();
virtual Result ListPlaceHolder(Out out_count, OutBuffer out_buf);
virtual Result GetContentCount(Out out_count);
virtual Result ListContentId(Out out_count, OutBuffer out_buf, u32 start_offset);
virtual Result GetSizeFromContentId(Out out_size, ContentId content_id);
virtual Result DisableForcibly();
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id);
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, u64 size);
virtual Result ReadContentIdFile(OutBuffer buf, ContentId content_id, u64 offset);
virtual Result GetRightsIdFromPlaceHolderId(Out out_rights_id, Out out_key_generation, PlaceHolderId placeholder_id);
virtual Result GetRightsIdFromContentId(Out out_rights_id, Out out_key_generation, ContentId content_id);
virtual Result WriteContentForDebug(ContentId content_id, u64 offset, InBuffer data);
virtual Result GetFreeSpaceSize(Out out_size);
virtual Result GetTotalSpaceSize(Out out_size);
virtual Result FlushPlaceHolder();
virtual Result GetSizeFromPlaceHolderId(Out out, PlaceHolderId placeholder_id);
virtual Result RepairInvalidFileAttribute();
virtual Result GetRightsIdFromPlaceHolderIdWithCache(Out out_rights_id, Out out_key_generation, PlaceHolderId placeholder_id, ContentId cache_content_id);
public:
DEFINE_SERVICE_DISPATCH_TABLE {};
};
}