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 "utility.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include "FormError.h"
|
#include "FormError.h"
|
||||||
|
#include "Form1_const.h"
|
||||||
|
|
||||||
namespace MasterEditorTWL {
|
namespace MasterEditorTWL {
|
||||||
|
|
||||||
@ -4060,16 +4061,16 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
|||||||
System::Boolean loadRom( System::String ^infile );
|
System::Boolean loadRom( System::String ^infile );
|
||||||
|
|
||||||
// ROMファイルの書き出し (SRL書き出しをラップ)
|
// ROMファイルの書き出し (SRL書き出しをラップ)
|
||||||
System::Boolean saveRom( System::String ^outname );
|
ECFormResult saveRom( System::String ^outname );
|
||||||
|
|
||||||
// SRLの読み込み
|
// SRLの読み込み
|
||||||
System::Boolean loadSrl( System::String ^srlfile );
|
System::Boolean loadSrl( System::String ^srlfile );
|
||||||
|
|
||||||
// SRLの書き出しと再読み込み
|
// SRLの書き出しと再読み込み
|
||||||
System::Boolean saveSrl( System::String ^infile, System::String ^outfile );
|
ECFormResult saveSrl( System::String ^infile, System::String ^outfile );
|
||||||
|
|
||||||
// SRLの書き出しのみ @ret 成否
|
// SRLの書き出しのみ @ret 成否
|
||||||
System::Boolean saveSrlCore( System::String ^infile, System::String ^outfile );
|
ECFormResult saveSrlCore( System::String ^infile, System::String ^outfile );
|
||||||
|
|
||||||
// tadの読み込み
|
// tadの読み込み
|
||||||
System::Boolean loadTad( System::String ^tadfile );
|
System::Boolean loadTad( System::String ^tadfile );
|
||||||
@ -4636,10 +4637,47 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( !this->saveRom( srlfile ) )
|
ECFormResult result = this->saveRom( srlfile );
|
||||||
|
if( result != ECFormResult::NOERROR )
|
||||||
{
|
{
|
||||||
this->errMsg( "マスターROMの作成に失敗しました。",
|
System::String^ msgJ = "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。";
|
||||||
"Making a master ROM failed." );
|
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;
|
return;
|
||||||
}
|
}
|
||||||
this->sucMsg( "マスターROMの作成が成功しました。", "A master ROM is made successfully." );
|
this->sucMsg( "マスターROMの作成が成功しました。", "A master ROM is made successfully." );
|
||||||
@ -4647,9 +4685,11 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
|||||||
}
|
}
|
||||||
catch( System::Exception ^ex )
|
catch( System::Exception ^ex )
|
||||||
{
|
{
|
||||||
(void)ex;
|
System::String ^msgJ = "マスターROMの作成に失敗しました。";
|
||||||
this->errMsg( "マスターROMの作成に失敗しました。",
|
System::String ^msgE = "Making a master ROM failed. ";
|
||||||
"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;
|
return;
|
||||||
}
|
}
|
||||||
} //stripItemMasterRom_Click()
|
} //stripItemMasterRom_Click()
|
||||||
@ -4738,19 +4778,58 @@ private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataSDKVer;
|
|||||||
// 更新後のSRLを別ファイルに作成
|
// 更新後のSRLを別ファイルに作成
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( !this->saveRom( srlfile ) )
|
ECFormResult result = this->saveRom( srlfile );
|
||||||
|
if( result != ECFormResult::NOERROR )
|
||||||
{
|
{
|
||||||
this->errMsg( "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。",
|
System::String^ msgJ = "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。";
|
||||||
"Making a master ROM failed. Therefore, a part of files can't be made." );
|
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;
|
return;
|
||||||
}
|
}
|
||||||
this->tboxFile->Text = srlfile;
|
this->tboxFile->Text = srlfile; // 成功してからテキストボックスに反映
|
||||||
}
|
}
|
||||||
catch( System::Exception ^ex )
|
catch( System::Exception ^ex )
|
||||||
{
|
{
|
||||||
(void)ex;
|
System::String ^msgJ = "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。";
|
||||||
this->errMsg( "マスターROMの作成に失敗しました。作成を中止するため一部のファイルは作成されません。",
|
System::String ^msgE = "Making a master ROM failed. Therefore, a part of files can't be made.";
|
||||||
"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;
|
return;
|
||||||
}
|
}
|
||||||
u16 crc; // SRL全体のCRCを計算する(書類に記述するため)
|
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書き出しをラップ)
|
// ファイルの書き出し (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 )
|
if( this->IsLoadTad )
|
||||||
{
|
{
|
||||||
// 一時ファイルにSRLを書き出しているのでその一時ファイルから出力ファイルを作成
|
// 一時ファイルにSRLを書き出しているのでその一時ファイルから出力ファイルを作成
|
||||||
System::String ^tmpsrl = this->getSplitTadTmpFile();
|
System::String ^tmpsrl = this->getSplitTadTmpFile();
|
||||||
result = this->saveSrl( tmpsrl, outfile );
|
result = this->saveSrl( tmpsrl, outfile );
|
||||||
if( result )
|
if( result != ECFormResult::NOERROR )
|
||||||
{
|
{
|
||||||
System::IO::File::Delete( tmpsrl );
|
System::IO::File::Delete( tmpsrl );
|
||||||
this->IsLoadTad = false; // 出力したSRLが次のソースとなる
|
this->IsLoadTad = false; // 出力したSRLが次のソースとなる
|
||||||
@ -158,25 +158,26 @@ System::Boolean Form1::loadSrl( System::String ^srlfile )
|
|||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
// SRLの保存
|
// 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 ) )
|
if( !System::IO::File::Exists( infile ) )
|
||||||
{
|
{
|
||||||
return false;
|
return ECFormResult::ERROR_FILE_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// コピーしたファイルにROMヘッダを上書き
|
// コピーしたファイルにROMヘッダを上書き
|
||||||
if( !this->saveSrlCore( infile, outfile ) )
|
ECFormResult result = this->saveSrlCore( infile, outfile );
|
||||||
|
if( result != ECFormResult::NOERROR )
|
||||||
{
|
{
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 再リード
|
// 再リード
|
||||||
this->loadSrl( outfile );
|
this->loadSrl( outfile );
|
||||||
return true;
|
return ECFormResult::NOERROR;
|
||||||
} // saveSrl()
|
} // saveSrl()
|
||||||
|
|
||||||
System::Boolean Form1::saveSrlCore( System::String ^infile, System::String ^outfile )
|
ECFormResult Form1::saveSrlCore( System::String ^infile, System::String ^outfile )
|
||||||
{
|
{
|
||||||
// ROM情報をフォームから取得してSRLバイナリに反映させる
|
// ROM情報をフォームから取得してSRLバイナリに反映させる
|
||||||
this->setSrlProperties();
|
this->setSrlProperties();
|
||||||
@ -184,13 +185,37 @@ System::Boolean Form1::saveSrlCore( System::String ^infile, System::String ^outf
|
|||||||
// ファイルをコピー
|
// ファイルをコピー
|
||||||
if( !(outfile->Equals( infile )) )
|
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ヘッダを上書き
|
// コピーしたファイルに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>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Form1_const.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\FormError.cpp"
|
RelativePath=".\FormError.cpp"
|
||||||
>
|
>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -333,6 +333,10 @@
|
|||||||
SubType="Designer"
|
SubType="Designer"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\Form1_const.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\FormError.h"
|
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"
|
SubType="Designer"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\Form1_const.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\FormError.h"
|
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"
|
SubType="Designer"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\Form1_const.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\MasterEditorTWL\MasterEditorTWL\FormError.h"
|
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