出力ファイルチェッカ:引数の数ではなく、拡張子が"XML"かどうかで分岐するように変更。ラッパーバッチファイルを追加。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@168 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2009-02-23 06:19:14 +00:00
parent fb2b916fcb
commit 35d292bfa8
9 changed files with 95 additions and 20 deletions

View File

@ -35,14 +35,18 @@ int main(array<System::String ^> ^args)
{
setDebugPrint( true );
}
if( argc <= 0 )
if( argc <= 1 )
{
throw (gcnew System::Exception("Argc is 0."));
throw (gcnew System::Exception("Argc is less than 2."));
}
else if( argc == 1 )
// 拡張子で判定
if( System::IO::Path::GetExtension(args[1])->ToUpper() == ".XML" )
{
System::String ^sheet = args[0];
// args[0] はダミー
System::String ^sheet = args[1];
DebugPrint( "Sheet file : " + sheet );
Console::Write( System::IO::Path::GetFileName( sheet ) + "\t" );
FilenameItem ^fItem = gcnew FilenameItem;
fItem->parseFilename( sheet );
@ -56,6 +60,7 @@ int main(array<System::String ^> ^args)
System::String ^target = args[1];
DebugPrint( "Original file : " + original );
DebugPrint( "Target file : " + target );
Console::Write( System::IO::Path::GetFileName( target ) + "\t" );
FilenameItem ^fItem = gcnew FilenameItem;
fItem->parseFilename( target );

View File

@ -115,7 +115,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL\MasterEditorTWL&quot;;C:\twlsdk\build\tools\makerom.TWL;C:\twlsdk\include;&quot;C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL_Common\user&quot;"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL\MasterEditorTWL&quot;;C:\twlsdk\build\tools\makerom.TWL;C:\twlsdk\include;&quot;C:\Documents and Settings\nishikawa_takeshi\My Documents\Visual Studio 2008\Projects\MasterEditorTWL_Common\launcher&quot;"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"

View File

@ -27,16 +27,16 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^orgSrl, System::Stri
// ROMヘッダの読み込み
ROM_Header rh;
FILE *fp = NULL;
if( fopen_s( &fp, chtarget, "rb" ) != NULL )
if( fopen_s( &fp, chtarget, "rb" ) != 0 )
{
throw (gcnew System::Exception("Fail to Open SRL File."));
throw (gcnew System::Exception("Fail to open the target SRL File."));
return;
}
// 1バイトをsizeof(~)だけリード (逆だと返り値がsizeof(~)にならないので注意)
(void)fseek( fp, 0, SEEK_SET ); // ROMヘッダはsrlの先頭から
if( fread( (void*)&rh, 1, sizeof(ROM_Header), fp ) != sizeof(ROM_Header) )
{
throw (gcnew System::Exception("Fail to Read ROM Header."));
throw (gcnew System::Exception("Fail to read the ROM Header."));
fclose(fp);
return;
}
@ -55,7 +55,7 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^orgSrl, System::Stri
DebugPrint( "--" );
if( rh.s.card_region_bitmap != region )
{
throw (gcnew System::Exception("Illegal Region in ROM Header."));
throw (gcnew System::Exception("Illegal Region in the ROM Header."));
return;
}
@ -65,7 +65,7 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^orgSrl, System::Stri
{
if( (rh.s.parental_control_rating_info[ogn] & OS_TWL_PCTL_OGNINFO_ENABLE_MASK) == 0 )
{
throw (gcnew System::Exception("Rating Ogn " + ogn.ToString() + " is not Enabled."));
throw (gcnew System::Exception("Rating Ogn " + ogn.ToString() + " is not enabled."));
return;
}
}
@ -75,7 +75,7 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^orgSrl, System::Stri
u8 rating = fItem->getRatingValue();
if( rh.s.parental_control_rating_info[ ogn ] != rating )
{
throw (gcnew System::Exception("Mismatch Rating Ogn " + ogn.ToString() + "."));
throw (gcnew System::Exception("mismatch Rating Ogn " + ogn.ToString() + "."));
return;
}
@ -101,7 +101,7 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^orgSrl, System::Stri
{
if( (ognlist->IndexOf(i) < 0) && (rh.s.parental_control_rating_info[i] != 0) )
{
throw (gcnew System::Exception("Rating Ogn " + i.ToString() + " is not Cleared in ROM Header."));
throw (gcnew System::Exception("Rating Ogn " + i.ToString() + " is not cleared in ROM Header."));
return;
}
}
@ -111,13 +111,13 @@ System::Void checkRom( FilenameItem ^fItem, System::String ^orgSrl, System::Stri
FILE *fp1 = NULL;
if( fopen_s( &fp1, chorg, "rb" ) != NULL )
{
throw (gcnew System::Exception("Fail to Open SRL File."));
throw (gcnew System::Exception("Fail to open the original SRL file."));
return;
}
FILE *fp2 = NULL;
if( fopen_s( &fp2, chtarget, "rb" ) != NULL )
{
throw (gcnew System::Exception("Fail to Open SRL File."));
throw (gcnew System::Exception("Fail to open the target SRL file."));
return;
}
// ファイルサイズをまずチェック
@ -231,12 +231,12 @@ System::Void verifyArea( FILE *fp1, FILE *fp2, const int offset, const int size
int len = (rest > VERIFY_AREA_BUFSIZE)?(VERIFY_AREA_BUFSIZE):(rest);
if( fread(buf1, 1, len, fp1) != len )
{
throw (gcnew System::Exception("In Verify, fail to fread"));
throw (gcnew System::Exception("In Verify, fail to fread fp1"));
return;
}
if( fread(buf2, 1, len, fp2) != len )
{
throw (gcnew System::Exception("In Verify, fail to fread"));
throw (gcnew System::Exception("In Verify, fail to fread fp2"));
return;
}
if( memcmp(buf1, buf2, len) != 0 )

View File

@ -125,7 +125,7 @@ System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
DebugPrint( "{0,-10} {1,-20} {2,-20}", fItem->ogn, rating, sItem->ratings[fItem->getOgnNumber()] );
if( sItem->ratings[fItem->getOgnNumber()] != rating )
{
throw (gcnew System::Exception("In Sheet, " + fItem->ogn + " is an Illegal String."));
throw (gcnew System::Exception("In Sheet, " + fItem->ogn + " mismatch."));
return;
}
@ -143,7 +143,7 @@ System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
// 提出確認書の文字列をチェック
if( sItem->ratings[ogn] != other )
{
throw (gcnew System::Exception("In Sheet, " + str + " is not a String for \"All ages\""));
throw (gcnew System::Exception("In Sheet, " + str + " mismatch a String for \"All ages\""));
return;
}
}
@ -165,7 +165,7 @@ System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
// 提出確認書の文字列をチェック
if( sItem->ratings[ogn] != unnecessary )
{
throw (gcnew System::Exception("In Sheet, " + str + " is not a String for \"Unnecessary\""));
throw (gcnew System::Exception("In Sheet, " + str + " mismatch a string for \"Unnecessary\""));
return;
}
}
@ -201,7 +201,7 @@ System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
DebugPrint( "{0,-10} {1,-20} {2,-20}", fItem->getOgnString(i), disable, sItem->ratings[i] );
if( sItem->ratings[i] != disable )
{
throw (gcnew System::Exception("In Sheet, " + fItem->getOgnString(i) + " is not a String for \"Disable\""));
throw (gcnew System::Exception("In Sheet, " + fItem->getOgnString(i) + " mismatch a string for \"Disable\""));
return;
}
}

View File

@ -0,0 +1,70 @@
@echo off
rem
rem mastering & comparing sample batch file
rem
rem Simple usage: SRLファイルをドラッグすると%output_path%にマスタリング
rem 結果を出力し、正しくできたか検証を行う
rem
rem 要確認変数: mastering_tool, comparing_tool, output_path
rem 補足: %~d0%~p0はバッチファイルのパスです
rem 補足: %~d1%~p1は各入力ファイルのパスです
rem
rem 引数チェック
set usage=USAGE: %~nx0 INPUT_FILE...
if ""%1"" == """" (
echo %usage%
echo 使用方法が間違っています。
echo SRLもしくはXMLをドラッグアンドドロップしてください。
echo.
goto end
)
rem パス設定
set checker_tool=%~d0%~p0MasterEditorTWLChecker.exe
set org_file=%~d0%~p0ORG.SRL
rem ループ開始 (%0を使うのはここまで、%1を使うのはここから、%2以降は使わない)
:begin
rem 出力パス設定
set input_file=%~dpnx1
set log_file=%~dp1%\log.txt
rem プログラム確認
if not exist "%checker_tool%" (
echo checker tool "%checker_tool%" is not found.
goto end
)
if not exist "%org_file%" (
echo original file "%org_file%" is not found.
goto end
)
if not exist "%input_file%" (
echo %input_file% is not found.
goto end
)
rem 処理本体
echo.
echo %~nx1をチェックします。
echo.
"%checker_tool%" "%org_file%" "%input_file%" >> "%log_file%"
if not %ERRORLEVEL% == 0 (
echo %input_file% のチェックに失敗しました。
rem goto end
)
rem 入力ファイルが残っているならbeginに戻る
shift
if ""%1"" neq """" goto begin
rem 終了 (キー入力待ち)
:end
echo.
echo すべてのチェックが終了しました。
pause