File: ParseUtauPluginInvoker.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,940 kB
  • sloc: cs: 160,836; java: 42,449; javascript: 7,966; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 234; php: 142; xml: 117; sh: 21
file content (99 lines) | stat: -rw-r--r-- 3,692 bytes parent folder | download | duplicates (6)
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" );
    }
}