mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
マスタエディタ:出力ファイルの作成エラーのエラー要因がわかるようにエラー処理とメッセージを変更。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@142 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
4fd390f4b1
commit
f6252a7eea
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,6 +8,7 @@
|
||||
#include "utility.h"
|
||||
#include "lang.h"
|
||||
#include "FormError.h"
|
||||
#include "Form1_const.h"
|
||||
|
||||
namespace MasterEditorTWL {
|
||||
|
||||
@ -4060,16 +4061,16 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
||||
System::Boolean loadRom( System::String ^infile );
|
||||
|
||||
// ROMファイルの書き出し (SRL書き出しをラップ)
|
||||
System::Boolean saveRom( System::String ^outname );
|
||||
ECFormResult saveRom( System::String ^outname );
|
||||
|
||||
// SRLの読み込み
|
||||
System::Boolean loadSrl( System::String ^srlfile );
|
||||
|
||||
// SRLの書き出しと再読み込み
|
||||
System::Boolean saveSrl( System::String ^infile, System::String ^outfile );
|
||||
ECFormResult saveSrl( System::String ^infile, System::String ^outfile );
|
||||
|
||||
// SRLの書き出しのみ @ret 成否
|
||||
System::Boolean saveSrlCore( System::String ^infile, System::String ^outfile );
|
||||
ECFormResult saveSrlCore( System::String ^infile, System::String ^outfile );
|
||||
|
||||
// tadの読み込み
|
||||
System::Boolean loadTad( System::String ^tadfile );
|
||||
@ -4636,10 +4637,47 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
||||
|
||||
try
|
||||
{
|
||||
if( !this->saveRom( srlfile ) )
|
||||
ECFormResult result = this->saveRom( srlfile );
|
||||
if( result != ECFormResult::NOERROR )
|
||||
{
|
||||
this->errMsg( "マスターROMの作成に失敗しました。",
|
||||
"Making a master ROM failed." );
|
||||
System::String^ msgJ = "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。";
|
||||
System::String^ msgE = "Making a master ROM failed. Therefore, a part of files can't be made.";
|
||||
switch( result )
|
||||
{
|
||||
case ECFormResult::ERROR_FILE_OPEN:
|
||||
msgJ += "\n\n原因:出力ファイルのオープンに失敗しました。";
|
||||
msgE += "\n\nReason: Opening an output file is failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_READ:
|
||||
msgJ += "\n\n原因:ファイルの読み込みに失敗しました。";
|
||||
msgE += "\n\nReason: Reading the file is failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_WRITE:
|
||||
msgJ += "\n\n原因:出力ファイルへの書き出しに失敗しました。";
|
||||
msgE += "\n\nReason: Writing the file is failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_COPY:
|
||||
msgJ += "\n\n原因:入力ROMデータファイルのコピーに失敗しました。";
|
||||
msgE += "\n\nReason: Copying the ROM data file failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_EXIST:
|
||||
msgJ += "\n\n原因:入力ROMデータファイルが元のフォルダに存在しないとき出力ファイルを作成できません。";
|
||||
msgE += "\n\nReason: When the input ROM data file doesn't exist in the original folder, output file can't be made.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_SIGN:
|
||||
msgJ += "\n\n原因:出力ファイルのディジタル署名の計算に失敗しました。";
|
||||
msgE += "\n\nReason: Calculation the digital signature of the output file failed.";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this->errMsg( msgJ, msgE );
|
||||
return;
|
||||
}
|
||||
this->sucMsg( "マスターROMの作成が成功しました。", "A master ROM is made successfully." );
|
||||
@ -4647,9 +4685,11 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
||||
}
|
||||
catch( System::Exception ^ex )
|
||||
{
|
||||
(void)ex;
|
||||
this->errMsg( "マスターROMの作成に失敗しました。",
|
||||
"Making a master ROM failed." );
|
||||
System::String ^msgJ = "マスターROMの作成に失敗しました。";
|
||||
System::String ^msgE = "Making a master ROM failed. ";
|
||||
msgJ += "\n\n例外:\n" + ex->ToString() + "\n" + ex->Message;
|
||||
msgE += "\n\n例外:\n" + ex->ToString() + "\n" + ex->Message;
|
||||
this->errMsg( msgJ, msgE );
|
||||
return;
|
||||
}
|
||||
} //stripItemMasterRom_Click()
|
||||
@ -4738,19 +4778,58 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
||||
// 更新後のSRLを別ファイルに作成
|
||||
try
|
||||
{
|
||||
if( !this->saveRom( srlfile ) )
|
||||
ECFormResult result = this->saveRom( srlfile );
|
||||
if( result != ECFormResult::NOERROR )
|
||||
{
|
||||
this->errMsg( "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。",
|
||||
"Making a master ROM failed. Therefore, a part of files can't be made." );
|
||||
System::String^ msgJ = "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。";
|
||||
System::String^ msgE = "Making a master ROM failed. Therefore, a part of files can't be made.";
|
||||
switch( result )
|
||||
{
|
||||
case ECFormResult::ERROR_FILE_OPEN:
|
||||
msgJ += "\n\n原因:出力ファイルのオープンに失敗しました。";
|
||||
msgE += "\n\nReason: Opening an output file is failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_READ:
|
||||
msgJ += "\n\n原因:ファイルの読み込みに失敗しました。";
|
||||
msgE += "\n\nReason: Reading the file is failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_WRITE:
|
||||
msgJ += "\n\n原因:出力ファイルへの書き出しに失敗しました。";
|
||||
msgE += "\n\nReason: Writing the file is failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_COPY:
|
||||
msgJ += "\n\n原因:入力ROMデータファイルのコピーに失敗しました。";
|
||||
msgE += "\n\nReason: Copying the ROM data file failed.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_EXIST:
|
||||
msgJ += "\n\n原因:入力ROMデータファイルが元のフォルダに存在しないとき出力ファイルを作成できません。";
|
||||
msgE += "\n\nReason: When the input ROM data file doesn't exist in the original folder, output file can't be made.";
|
||||
break;
|
||||
|
||||
case ECFormResult::ERROR_FILE_SIGN:
|
||||
msgJ += "\n\n原因:出力ファイルのディジタル署名の計算に失敗しました。";
|
||||
msgE += "\n\nReason: Calculation the digital signature of the output file failed.";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this->errMsg( msgJ, msgE );
|
||||
return;
|
||||
}
|
||||
this->tboxFile->Text = srlfile;
|
||||
this->tboxFile->Text = srlfile; // 成功してからテキストボックスに反映
|
||||
}
|
||||
catch( System::Exception ^ex )
|
||||
{
|
||||
(void)ex;
|
||||
this->errMsg( "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。",
|
||||
"Making a master ROM failed. Therefore, a part of files can't be made." );
|
||||
System::String ^msgJ = "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。";
|
||||
System::String ^msgE = "Making a master ROM failed. Therefore, a part of files can't be made.";
|
||||
msgJ += "例外:\n" + ex->ToString() + "\n" + ex->Message;
|
||||
msgE += "例外:\n" + ex->ToString() + "\n" + ex->Message;
|
||||
this->errMsg( msgJ, msgE );
|
||||
return;
|
||||
}
|
||||
u16 crc; // SRL全体のCRCを計算する(書類に記述するため)
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
namespace MasterEditorTWL {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Type : enum class
|
||||
// Name : ECFormResult
|
||||
//
|
||||
// Description : フォーム上のエラーを宣言
|
||||
// -------------------------------------------------------------------
|
||||
enum class ECFormResult
|
||||
{
|
||||
NOERROR = 0,
|
||||
// 特定の必要がない雑多なエラー
|
||||
ERROR,
|
||||
// ファイル操作
|
||||
ERROR_FILE_OPEN,
|
||||
ERROR_FILE_READ,
|
||||
ERROR_FILE_WRITE,
|
||||
ERROR_FILE_COPY,
|
||||
ERROR_FILE_EXIST,
|
||||
ERROR_FILE_SIGN, // ファイルに署名がつけられなかった
|
||||
|
||||
}; //enum class ECFormResult
|
||||
|
||||
} // end of namespace MasterEditorTWL
|
||||
@ -57,15 +57,15 @@ System::Boolean Form1::loadRom( System::String ^infile )
|
||||
// ----------------------------------------------
|
||||
// ファイルの書き出し (TAD/SRL書き出しをラップ)
|
||||
// ----------------------------------------------
|
||||
System::Boolean Form1::saveRom( System::String ^outfile )
|
||||
ECFormResult Form1::saveRom( System::String ^outfile )
|
||||
{
|
||||
System::Boolean result = false;
|
||||
ECFormResult result = ECFormResult::NOERROR;
|
||||
if( this->IsLoadTad )
|
||||
{
|
||||
// 一時ファイルにSRLを書き出しているのでその一時ファイルから出力ファイルを作成
|
||||
System::String ^tmpsrl = this->getSplitTadTmpFile();
|
||||
result = this->saveSrl( tmpsrl, outfile );
|
||||
if( result )
|
||||
if( result != ECFormResult::NOERROR )
|
||||
{
|
||||
System::IO::File::Delete( tmpsrl );
|
||||
this->IsLoadTad = false; // 出力したSRLが次のソースとなる
|
||||
@ -158,25 +158,26 @@ System::Boolean Form1::loadSrl( System::String ^srlfile )
|
||||
// ----------------------------------------------
|
||||
// SRLの保存
|
||||
// ----------------------------------------------
|
||||
System::Boolean Form1::saveSrl( System::String ^infile, System::String ^outfile )
|
||||
ECFormResult Form1::saveSrl( System::String ^infile, System::String ^outfile )
|
||||
{
|
||||
if( !System::IO::File::Exists( infile ) )
|
||||
{
|
||||
return false;
|
||||
return ECFormResult::ERROR_FILE_EXIST;
|
||||
}
|
||||
|
||||
// コピーしたファイルにROMヘッダを上書き
|
||||
if( !this->saveSrlCore( infile, outfile ) )
|
||||
ECFormResult result = this->saveSrlCore( infile, outfile );
|
||||
if( result != ECFormResult::NOERROR )
|
||||
{
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
// 再リード
|
||||
this->loadSrl( outfile );
|
||||
return true;
|
||||
return ECFormResult::NOERROR;
|
||||
} // saveSrl()
|
||||
|
||||
System::Boolean Form1::saveSrlCore( System::String ^infile, System::String ^outfile )
|
||||
ECFormResult Form1::saveSrlCore( System::String ^infile, System::String ^outfile )
|
||||
{
|
||||
// ROM情報をフォームから取得してSRLバイナリに反映させる
|
||||
this->setSrlProperties();
|
||||
@ -184,13 +185,37 @@ System::Boolean Form1::saveSrlCore( System::String ^infile, System::String ^outf
|
||||
// ファイルをコピー
|
||||
if( !(outfile->Equals( infile )) )
|
||||
{
|
||||
System::IO::File::Copy( infile, outfile, true );
|
||||
try
|
||||
{
|
||||
System::IO::File::Copy( infile, outfile, true );
|
||||
}
|
||||
catch( System::Exception ^ex )
|
||||
{
|
||||
(void)ex;
|
||||
return ECFormResult::ERROR_FILE_COPY;
|
||||
}
|
||||
}
|
||||
|
||||
// コピーしたファイルにROMヘッダを上書き
|
||||
if( this->hSrl->writeToFile( outfile ) != ECSrlResult::NOERROR )
|
||||
ECSrlResult srlRes = this->hSrl->writeToFile( outfile );
|
||||
if( srlRes != ECSrlResult::NOERROR )
|
||||
{
|
||||
return false;
|
||||
ECFormResult formRes = ECFormResult::NOERROR;
|
||||
switch( srlRes )
|
||||
{
|
||||
case ECSrlResult::ERROR_FILE_OPEN: formRes = ECFormResult::ERROR_FILE_OPEN; break;
|
||||
case ECSrlResult::ERROR_FILE_WRITE: formRes = ECFormResult::ERROR_FILE_WRITE; break;
|
||||
case ECSrlResult::ERROR_FILE_READ: formRes = ECFormResult::ERROR_FILE_READ; break;
|
||||
case ECSrlResult::ERROR_SIGN_ENCRYPT:
|
||||
case ECSrlResult::ERROR_SIGN_DECRYPT:
|
||||
case ECSrlResult::ERROR_SIGN_VERIFY:
|
||||
formRes = ECFormResult::ERROR_FILE_SIGN;
|
||||
break;
|
||||
default:
|
||||
formRes = ECFormResult::ERROR;
|
||||
break;
|
||||
}
|
||||
return formRes;
|
||||
}
|
||||
return true;
|
||||
return ECFormResult::NOERROR;
|
||||
}
|
||||
|
||||
@ -332,6 +332,10 @@
|
||||
>
|
||||
</File>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Form1_const.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\FormError.cpp"
|
||||
>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -333,6 +333,10 @@
|
||||
SubType="Designer"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\Form1_const.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\FormError.h"
|
||||
>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -333,6 +333,10 @@
|
||||
SubType="Designer"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\Form1_const.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\FormError.h"
|
||||
>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -333,6 +333,10 @@
|
||||
SubType="Designer"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\Form1_const.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\FormError.h"
|
||||
>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user