1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
using System;
using System.IO;
using System.Windows.Forms;
class ParseUtauPluginInvoker{
//
public static void Main( string[] args ){
string base_dir = System.Windows.Forms.Application.StartupPath;
//Console.WriteLine( "base_dir=" + base_dir );
string out_file = Path.Combine( Path.Combine( Path.Combine( Path.Combine( Path.Combine( Path.Combine( base_dir, "Cadencii" ), "bin" ), "x86" ), "Release" ), "script" ), "UTAU Plugin Manager.txt" );
//Console.WriteLine( "out_file=" + out_file );
string in_file1 = Path.Combine( Path.Combine( base_dir, "ScriptImplement" ), "Utau Plugin Invoker.cs" );
string in_file2 = Path.Combine( Path.Combine( base_dir, "ScriptImplement" ), "UTAU Plugin Manager.cs" );
//Console.WriteLine( "in_file1=" + in_file1 );
//Console.WriteLine( "in_file2=" + in_file2 );
if( !File.Exists( in_file1 ) ){
Console.WriteLine( "error; file not found '" + in_file1 + "'" );
System.Environment.ExitCode = -1;
return;
}
if( !File.Exists( in_file2 ) ){
Console.WriteLine( "error; file not found '" + in_file2 + "'" );
System.Environment.ExitCode = -1;
return;
}
// base_dir trunk
// in_file2 trunk\ScriptImplement\Utau Plugin Invoker.cs
// in_file1 trunk\ScriptImplement\UTAU Plugin Manager.cs
// out_file trunk\Cadencii\bin\x86\Release\UTAU Plugin Manager.txt
// ev[gǂݍ
string template = "";
StreamReader sr = null;
try {
sr = new StreamReader( in_file1 );
string line = "";
int count = 0;
//Console.WriteLine( "'" + in_file1 + "'" );
while ( (line = sr.ReadLine()) != null ) {
//Console.WriteLine( line );
line = line.Replace( "\"", "\\\"" );
line = line.Replace( "Utau_Plugin_Invoker", "{0}" );
line = line.Replace( "E:\\Program Files\\UTAU\\plugins\\TestUtauScript\\plugin.txt", "{1}" );
template += (count == 0 ? "" : "\n ") + "\"" + line + "\\n\" +";
count++;
}
template += " \"\"";
} catch ( Exception ex ) {
Console.WriteLine( ex.StackTrace );
} finally {
if ( sr != null ) {
try {
sr.Close();
} catch {
}
}
}
StreamWriter sw = null;
sr = null;
try {
sw = new StreamWriter( out_file );
sr = new StreamReader( in_file2 );
string line = "";
//Console.WriteLine( "'" + in_file2 + "'" );
while ( (line = sr.ReadLine()) != null ) {
//Console.WriteLine( line );
line = line.Replace( "\"@@TEXT@@\"", template );
sw.WriteLine( line );
}
} catch ( Exception ex ) {
Console.WriteLine( ex.StackTrace );
} finally {
if ( sr != null ) {
try {
sr.Close();
} catch {
}
}
if ( sw != null ) {
try {
sw.Close();
} catch {
}
}
}
return;
}
private static void printUsage()
{
Console.WriteLine( "ParseUtauPluginInvoker" );
Console.WriteLine( "Copyright (C) 2011 kbinani" );
Console.WriteLine( "Usage:" );
Console.WriteLine( " ParseUtauPluginInvoker" );
}
}
|