mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
82 lines
2.0 KiB
C++
82 lines
2.0 KiB
C++
#include <wchar.h>
|
|
#include <string.h>
|
|
#include <nn/fs.h>
|
|
#include "exsave.h"
|
|
#include <nn/fs/fs_ResultPrivate.h>
|
|
#include <nn/fs/CTR/MPCore/fs_ApiForHwCheck.h>
|
|
//#include <nn/am/am_ApiSystemMenu.h>
|
|
//#include <nn/am/am_ApiLocalImporter.h>
|
|
|
|
|
|
extern "C" {
|
|
extern u8* ICON_BEGIN[];
|
|
extern u8* ICON_END[];
|
|
|
|
const void* ICON = ICON_BEGIN;
|
|
const size_t ICON_SIZE = ICON_END-ICON_BEGIN;
|
|
}
|
|
|
|
|
|
//セーブ作成、成功時はマウント状態
|
|
myResult ExSave::Create(u32 entryDir,u32 entryFile)
|
|
{
|
|
if ( IsMounted )return RESULT_ALREADY_MOUNT;
|
|
LastNnResult = nn::fs::CreateExtSaveData(OWN_UID,ICON,ICON_SIZE,entryDir,entryFile);
|
|
if (LastNnResult.IsFailure())return RESULT_FAIL_CREATE;
|
|
LastNnResult = nn::fs::MountExtSaveData(devName,OWN_UID);
|
|
if (LastNnResult.IsFailure())return RESULT_FAIL_MOUNT;
|
|
//LastNnResult = nn::fs::TryCreateDirectory(root_w);
|
|
//if (LastNnResult.IsFailure()){
|
|
// nn::fs::Unmount(devName);
|
|
// return RESULT_FAIL_MOUNT;
|
|
//}
|
|
IsMounted = true;
|
|
return RESULT_OK;
|
|
}
|
|
|
|
//空き容量
|
|
s64 ExSave::GetFreeSize()
|
|
{
|
|
if (IsMounted==false)if(MountCore()==false)return 0;
|
|
s64 a,b;
|
|
LastNnResult = nn::fs::GetSdmcSize(&a,&b);
|
|
if (IsMounted==false)Unmount();
|
|
if (LastNnResult.IsFailure())return 0;
|
|
return b;
|
|
}
|
|
|
|
//削除
|
|
bool ExSave::Delete()
|
|
{
|
|
LastNnResult = nn::fs::DeleteExtSaveData(OWN_UID);
|
|
//if (nn::fs::ResultNotFound().Includes(LastNnResult))return RESULT_NOT_FOUND;
|
|
return LastNnResult.IsSuccess();
|
|
}
|
|
|
|
|
|
//マウント
|
|
bool ExSave::MountCore()
|
|
{
|
|
LastNnResult = nn::fs::MountExtSaveData(devName,OWN_UID);
|
|
return LastNnResult.IsSuccess();
|
|
}
|
|
|
|
//フォーマット情報
|
|
void ExSave::GetFormatInfoCore(tArcInfo *ifo)
|
|
{
|
|
LastNnResult = nn::fs::GetExtSaveDataFormatInfo(&ifo->FileEntry,&ifo->DirEntry,OWN_UID);
|
|
}
|
|
|
|
|
|
//コンストラクタ
|
|
ExSave::ExSave()
|
|
{
|
|
PrdCode[0] = 0;
|
|
strcpy(devName,"exsave:");
|
|
SetRootPath(L"exsave:");
|
|
|
|
}
|
|
|
|
|
|
|