Esempio n. 1
0
 static void println( BufferedWriter sw, string message ) {
     sw.write( message );
     sw.newLine();
     Console.WriteLine( message );
 }
Esempio n. 2
0
 static void print( BufferedWriter sw, string message ) {
     sw.write( message );
     Console.Write( message );
 }
Esempio n. 3
0
        public static void Main( string[] args ) {
#if DEBUG
            _hidekeys = true;
#endif
            BufferedWriter sw = null;
            try {
                sw = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( "result.txt" ), "Shift_JIS" ) );
                VocaloSysUtil.init();
                string editor2 = VocaloSysUtil.getEditorPath( SynthesizerType.VOCALOID2 );
                sw.write( new string( '#', 72 ) );
                sw.newLine();
                sw.write( "VOCALOID2" );
                sw.newLine();
                SingerConfigSys sys2 = VocaloSysUtil.getSingerConfigSys( SynthesizerType.VOCALOID2 );
                write( sw, editor2, sys2 );

                sw.write( new string( '#', 72 ) );
                sw.newLine();
                sw.write( "VOCALOID1" );
                sw.newLine();
                string editor1 = VocaloSysUtil.getEditorPath( SynthesizerType.VOCALOID1 );
                SingerConfigSys sys1 = VocaloSysUtil.getSingerConfigSys( SynthesizerType.VOCALOID1 );
                write( sw, editor1, sys1 );
            } catch ( Exception ex ) {
            } finally {
                if ( sw != null ) {
                    try {
                        sw.close();
                    } catch ( Exception ex ) {
                    }
                }
            }

            if ( _hidekeys ) {
                // 一度全体を読み込み、隠す必要のあるID文字列を抽出
                BufferedReader br2 = null;
                try {
                    br2 = new BufferedReader( new InputStreamReader( new FileInputStream( "result.txt" ), "Shift_JIS" ) );
                    String line = "";
                    String[] headers = new String[]{
                        "HKLM\\SOFTWARE\\VOCALOID\\APPLICATION\\",
                        "HKLM\\SOFTWARE\\VOCALOID\\DATABASE\\EXPRESSION\\",
                        "HKLM\\SOFTWARE\\VOCALOID2\\APPLICATION\\",
                        "HKLM\\SOFTWARE\\VOCALOID2\\DATABASE\\EXPRESSION\\",
                        "HKLM\\SOFTWARE\\VOCALOID\\SKIN\\",
                        "HKLM\\SOFTWARE\\VOCALOID2\\DATABASE\\VOICE\\",
                        "HKLM\\SOFTWARE\\VOCALOID\\DATABASE\\VOICE\\", };

                    while ( (line = br2.readLine()) != null ) {
                        String[] spl = PortUtil.splitString( line, '\t' );
                        if ( spl.Length < 3 ) {
                            continue;
                        }
                        String s = spl[0];

                        // ID(?)
                        foreach( String h in headers ){
                            if( !s.StartsWith( h ) ){
                                continue;
                            }
                            String keys = "";
                            try {
                                keys = s.Substring( PortUtil.getStringLength( h ) + 17, 4 );
                            } catch ( Exception ex ) {
                                continue;
                            }
#if DEBUG
                            sout.println( "Main; keys=" + keys );
#endif
                            if( !keys.Equals( "KEYS" ) ){
                                continue;
                            }
                            String key = s.Substring( PortUtil.getStringLength( h ), 16 );
#if DEBUG
                            sout.println( "Main; key=" + key );
#endif
                            addIdMap( key );
                        }

                        // handle(?)
                        if ( spl[1] == "TIME" || spl[1] == "STANDARD" ) {
                            if( isId( spl[2] ) ){
                                addIdMap( spl[2] );
                            }
                        } else if ( spl[1] == "default" ) {
                            if ( tryParseUInt128( spl[2] ) ) {
                                addHandleMap( spl[2] );
                            }
                        } else {
                            if( isId( spl[1] ) && tryParseUInt128( spl[2] ) ){
                                addIdMap( spl[1] );
                                addHandleMap( spl[2] );
                            }
                        }
                    }
                } catch ( Exception ex ) {
                    serr.println( "Main; ex=" + ex );
                } finally {
                    if ( br2 != null ) {
                        try {
                            br2.close();
                        } catch ( Exception ex2 ) {
                            serr.println( "Main; ex2=" + ex2 );
                        }
                    }
                }
                
                String tmp = PortUtil.createTempFile();
                PortUtil.deleteFile( tmp );
                PortUtil.copyFile( "result.txt", tmp );
                PortUtil.deleteFile( "result.txt" );
                BufferedReader br = null;
                BufferedWriter bw = null;

                try {
                    br = new BufferedReader( new InputStreamReader( new FileInputStream( tmp ), "Shift_JIS" ) );
                    bw = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( "result.txt" ), "Shift_JIS" ) );
                    String line = "";
                    while ( (line = br.readLine()) != null ) {
                        foreach ( String from in _map_id.Keys ) {
                            String to = _map_id[from];
                            line = line.Replace( from, to );
                        }
                        bw.write( line );
                        bw.newLine();
                    }
                } catch ( Exception ex ) {
                } finally {
                    if ( br != null ) {
                        try {
                            br.close();
                        } catch ( Exception ex2 ) {
                        }
                        PortUtil.deleteFile( tmp );
                    }
                    if ( bw != null ) {
                        try {
                            bw.close();
                        } catch ( Exception ex2 ) {
                        }
                    }
                }
            }
#if DEBUG
            Console.WriteLine( "tryParseUInt128(\"403034329006c1cf2c401d4664d3492b\")=" + tryParseUInt128( "403034329006c1cf2c401d4664d3492b" ) );
            Console.Write( "hit any key to exit..." );
            Console.Read();
#endif
        }