mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
カレントパスの管理をFSに任せるのをやめて自前で管理するように変更。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@891 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
b73bbdbef5
commit
5271be0a70
@ -83,6 +83,7 @@ static const u8 sClearData[CLEAR_DATA_SIZE] =
|
|||||||
|
|
||||||
static FSDirectoryEntryInfo sEntryInfo;
|
static FSDirectoryEntryInfo sEntryInfo;
|
||||||
static NAMTitleId sTitleIdArray[TITLE_LIST_MAX];
|
static NAMTitleId sTitleIdArray[TITLE_LIST_MAX];
|
||||||
|
static char sCurrentFullPath[FS_ENTRY_LONGNAME_MAX];
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
内部関数宣言
|
内部関数宣言
|
||||||
@ -141,7 +142,7 @@ BOOL NAMUT_Format(void)
|
|||||||
Description: 指定ディレクトリ以下を消去します。
|
Description: 指定ディレクトリ以下を消去します。
|
||||||
指定ディレクトリ自体は残ります。
|
指定ディレクトリ自体は残ります。
|
||||||
|
|
||||||
Arguments: path : 絶対パス
|
Arguments: path : 絶対パス(スラッシュを含めない)
|
||||||
|
|
||||||
Returns: None
|
Returns: None
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
@ -160,14 +161,6 @@ static BOOL NAMUTi_DeleteNandDirectory(const char *path)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// カレントディレクトリを設定する
|
|
||||||
if (!FS_SetCurrentDirectory(path))
|
|
||||||
{
|
|
||||||
SDK_ASSERTMSG(0, "Fail! FS_SetCurrentDirectory(%s) in %s\n", path, __func__);
|
|
||||||
FS_CloseDirectory(&dir);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ディレクトリの中身を読む
|
// ディレクトリの中身を読む
|
||||||
while (FS_ReadDirectory(&dir, &entryInfo))
|
while (FS_ReadDirectory(&dir, &entryInfo))
|
||||||
{
|
{
|
||||||
@ -177,24 +170,24 @@ static BOOL NAMUTi_DeleteNandDirectory(const char *path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STD_CopyLString( sCurrentFullPath, path, FS_ENTRY_LONGNAME_MAX );
|
||||||
|
STD_ConcatenateLString(sCurrentFullPath, "/", FS_ENTRY_LONGNAME_MAX);
|
||||||
|
STD_ConcatenateLString(sCurrentFullPath, entryInfo.longname, FS_ENTRY_LONGNAME_MAX);
|
||||||
|
|
||||||
// ディレクトリ
|
// ディレクトリ
|
||||||
if (entryInfo.attributes & FS_ATTRIBUTE_IS_DIRECTORY)
|
if (entryInfo.attributes & FS_ATTRIBUTE_IS_DIRECTORY)
|
||||||
{
|
{
|
||||||
ret &= FS_DeleteDirectoryAuto(entryInfo.longname);
|
ret &= FS_DeleteDirectoryAuto(sCurrentFullPath);
|
||||||
SDK_ASSERTMSG(ret, "Fail! FS_DeleteDirectoryAuto(%s) in %s\n", entryInfo.longname, __func__);
|
SDK_ASSERTMSG(ret, "Fail! FS_DeleteDirectoryAuto(%s) in %s\n", sCurrentFullPath, __func__);
|
||||||
}
|
}
|
||||||
// ファイル
|
// ファイル
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret &= FS_DeleteFileAuto(entryInfo.longname);
|
ret &= FS_DeleteFileAuto(sCurrentFullPath);
|
||||||
SDK_ASSERTMSG(ret, "Fail! FS_DeleteFileAuto(%s) in %s\n", entryInfo.longname, __func__);
|
SDK_ASSERTMSG(ret, "Fail! FS_DeleteFileAuto(%s) in %s\n", sCurrentFullPath, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// カレントディレクトリを元に戻します
|
|
||||||
ret &= FS_SetCurrentDirectory("..");
|
|
||||||
SDK_ASSERTMSG(ret, "Fail! FS_SetCurrentDirectory(..) in %s\n", __func__);
|
|
||||||
|
|
||||||
// ディレクトリを閉じる
|
// ディレクトリを閉じる
|
||||||
FS_CloseDirectory(&dir);
|
FS_CloseDirectory(&dir);
|
||||||
|
|
||||||
@ -226,7 +219,7 @@ static BOOL NAMUTi_DeleteNonprotectedTitle(void)
|
|||||||
|
|
||||||
Description: User App タイトルの削除を行います。
|
Description: User App タイトルの削除を行います。
|
||||||
|
|
||||||
Arguments: path
|
Arguments: path : 絶対パス(スラッシュを含まない)
|
||||||
|
|
||||||
Returns: None
|
Returns: None
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
@ -245,14 +238,6 @@ static BOOL NAMUTi_DeleteNonprotectedTitleEntity(const char* path)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// カレントディレクトリを設定する
|
|
||||||
if (!FS_SetCurrentDirectory(path))
|
|
||||||
{
|
|
||||||
SDK_ASSERTMSG(0, "Fail! FS_SetCurrentDirectory(%s) in %s\n", path, __func__);
|
|
||||||
FS_CloseDirectory(&dir);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ディレクトリの中身を読む
|
// ディレクトリの中身を読む
|
||||||
while (FS_ReadDirectory(&dir, &entryInfo))
|
while (FS_ReadDirectory(&dir, &entryInfo))
|
||||||
{
|
{
|
||||||
@ -270,16 +255,16 @@ static BOOL NAMUTi_DeleteNonprotectedTitleEntity(const char* path)
|
|||||||
// プロテクト対象でない場合ディレクトリごと消去する
|
// プロテクト対象でない場合ディレクトリごと消去する
|
||||||
if (!(titlePropety & PROTECT_TITLE_PROPERTY))
|
if (!(titlePropety & PROTECT_TITLE_PROPERTY))
|
||||||
{
|
{
|
||||||
ret &= FS_DeleteDirectoryAuto(entryInfo.longname);
|
STD_CopyLString( sCurrentFullPath, path, FS_ENTRY_LONGNAME_MAX );
|
||||||
SDK_ASSERTMSG(ret, "Fail! FS_DeleteDirectoryAuto(%s) in %s\n", entryInfo.longname, __func__);
|
STD_ConcatenateLString(sCurrentFullPath, "/", FS_ENTRY_LONGNAME_MAX);
|
||||||
|
STD_ConcatenateLString(sCurrentFullPath, entryInfo.longname, FS_ENTRY_LONGNAME_MAX);
|
||||||
|
|
||||||
|
ret &= FS_DeleteDirectoryAuto(sCurrentFullPath);
|
||||||
|
SDK_ASSERTMSG(ret, "Fail! FS_DeleteDirectoryAuto(%s) in %s\n", sCurrentFullPath, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// カレントディレクトリを元に戻します
|
|
||||||
ret &= FS_SetCurrentDirectory("..");
|
|
||||||
SDK_ASSERTMSG(ret, "Fail! FS_SetCurrentDirectory(..) in %s\n", __func__);
|
|
||||||
|
|
||||||
// ディレクトリを閉じる
|
// ディレクトリを閉じる
|
||||||
ret &= FS_CloseDirectory(&dir);
|
ret &= FS_CloseDirectory(&dir);
|
||||||
SDK_ASSERTMSG(ret, "Fail! FS_CloseDirectory() in %s\n", __func__);
|
SDK_ASSERTMSG(ret, "Fail! FS_CloseDirectory() in %s\n", __func__);
|
||||||
@ -361,12 +346,16 @@ static BOOL NAMUTi_ClearSavedata(const char* path, BOOL fill)
|
|||||||
// ファイル構造体初期化
|
// ファイル構造体初期化
|
||||||
FS_InitFile(&file);
|
FS_InitFile(&file);
|
||||||
|
|
||||||
|
|
||||||
// セーブファイルオープン
|
// セーブファイルオープン
|
||||||
if (!FS_OpenFileEx(&file, path, (FS_FILEMODE_R|FS_FILEMODE_W)))
|
if (!FS_OpenFileEx(&file, path, (FS_FILEMODE_R|FS_FILEMODE_W)))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// 月曜にセーブデータに対してマウントする関数ができるのでそれ待ち
|
||||||
|
|
||||||
// セーブファイルを0xFFでクリア
|
// セーブファイルを0xFFでクリア
|
||||||
if (fill)
|
if (fill)
|
||||||
{
|
{
|
||||||
@ -378,6 +367,7 @@ static BOOL NAMUTi_ClearSavedata(const char* path, BOOL fill)
|
|||||||
FS_WriteFile(&file, sClearData, (s32)filesize);
|
FS_WriteFile(&file, sClearData, (s32)filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// セーブファイルに対してマウント
|
// セーブファイルに対してマウント
|
||||||
for (drive[0]='Z'; drive[0]>='A'; drive[0]--)
|
for (drive[0]='Z'; drive[0]>='A'; drive[0]--)
|
||||||
{
|
{
|
||||||
@ -408,6 +398,8 @@ static BOOL NAMUTi_ClearSavedata(const char* path, BOOL fill)
|
|||||||
// アンマウント
|
// アンマウント
|
||||||
FATFS_UnmountDrive(drive);
|
FATFS_UnmountDrive(drive);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
// ファイルクローズ
|
// ファイルクローズ
|
||||||
FS_CloseFile(&file);
|
FS_CloseFile(&file);
|
||||||
@ -459,10 +451,10 @@ static BOOL NAMUTi_FillFile(const char* path)
|
|||||||
|
|
||||||
Returns: None.
|
Returns: None.
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void NAMUT_DrawNandTree(void)
|
void NAMUT_DrawNandTree(void)
|
||||||
{
|
{
|
||||||
NAMUTi_DrawNandTree(0, "nand:/");
|
MI_CpuClear8( sCurrentFullPath, sizeof(sCurrentFullPath) );
|
||||||
|
NAMUTi_DrawNandTree(0, "nand:");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
@ -470,7 +462,7 @@ void NAMUT_DrawNandTree(void)
|
|||||||
|
|
||||||
Description: 指定パスのツリー情報をプリント出力します(再帰関数)
|
Description: 指定パスのツリー情報をプリント出力します(再帰関数)
|
||||||
|
|
||||||
Arguments: ...
|
Arguments: path : 絶対パス指定(スラッシュを含めない)
|
||||||
|
|
||||||
Returns: None.
|
Returns: None.
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
@ -478,8 +470,16 @@ void NAMUT_DrawNandTree(void)
|
|||||||
static void NAMUTi_DrawNandTree(s32 depth, const char *path)
|
static void NAMUTi_DrawNandTree(s32 depth, const char *path)
|
||||||
{
|
{
|
||||||
FSFile dir;
|
FSFile dir;
|
||||||
|
char* pSlash = STD_SearchCharReverse( sCurrentFullPath, '/' );
|
||||||
PrintDirectory(depth, path);
|
|
||||||
|
if (pSlash != NULL)
|
||||||
|
{
|
||||||
|
PrintDirectory(depth, pSlash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintDirectory(depth, path);
|
||||||
|
}
|
||||||
|
|
||||||
// 深さ制限
|
// 深さ制限
|
||||||
if (depth > DIRECTORY_DEPTH_MAX)
|
if (depth > DIRECTORY_DEPTH_MAX)
|
||||||
@ -488,20 +488,15 @@ static void NAMUTi_DrawNandTree(s32 depth, const char *path)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// カレントパスを設定
|
||||||
|
STD_CopyLString( sCurrentFullPath, path, FS_ENTRY_LONGNAME_MAX );
|
||||||
|
|
||||||
FS_InitFile(&dir);
|
FS_InitFile(&dir);
|
||||||
|
|
||||||
// 引数で指定されたディレクトリを開く
|
// 引数で指定されたディレクトリを開く
|
||||||
if (!FS_OpenDirectory(&dir, path, (FS_FILEMODE_R|FS_FILEMODE_W)))
|
if (!FS_OpenDirectory(&dir, sCurrentFullPath, (FS_FILEMODE_R|FS_FILEMODE_W)))
|
||||||
{
|
{
|
||||||
OS_TPrintf("%d Fail! FS_OpenDirectory(%s)\n", __LINE__, path);
|
OS_TPrintf("%d Fail! FS_OpenDirectory(%s)\n", __LINE__, sCurrentFullPath);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// カレントディレクトリを設定する
|
|
||||||
if (!FS_SetCurrentDirectory(path))
|
|
||||||
{
|
|
||||||
OS_TPrintf("Fail! FS_SetCurrentDirectory(%s)\n", path);
|
|
||||||
FS_CloseDirectory(&dir);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,19 +512,21 @@ static void NAMUTi_DrawNandTree(s32 depth, const char *path)
|
|||||||
// ディレクトリであれば再帰呼び出し
|
// ディレクトリであれば再帰呼び出し
|
||||||
if (!(sEntryInfo.attributes & FS_ATTRIBUTE_IS_DIRECTORY))
|
if (!(sEntryInfo.attributes & FS_ATTRIBUTE_IS_DIRECTORY))
|
||||||
{
|
{
|
||||||
// PrintFile(depth, sEntryInfo.longname);
|
PrintFile(depth, sEntryInfo.longname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NAMUTi_DrawNandTree(depth + 1, sEntryInfo.longname);
|
STD_ConcatenateLString(sCurrentFullPath, "/", FS_ENTRY_LONGNAME_MAX);
|
||||||
|
STD_ConcatenateLString(sCurrentFullPath, sEntryInfo.longname, FS_ENTRY_LONGNAME_MAX);
|
||||||
|
NAMUTi_DrawNandTree(depth + 1, sCurrentFullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// カレントディレクトリを元に戻します
|
// カレントパスを削る
|
||||||
if (!FS_SetCurrentDirectory(".."))
|
if (pSlash != NULL)
|
||||||
{
|
{
|
||||||
OS_TPrintf("Fail! FS_SetCurrentDirectory(..)\n");
|
*pSlash = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_CloseDirectory(&dir);
|
FS_CloseDirectory(&dir);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user