File: extractFromg2pa.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 35,880 kB
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (40 lines) | stat: -rw-r--r-- 1,388 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
using System;
using System.IO;
using System.Text;
class ExtractFromG2PA {
    public static void Main( string[] args ) {
        string file = args[0];

        string tfile = Path.GetTempFileName();
        using ( FileStream sw = new FileStream( tfile, FileMode.Create, FileAccess.Write ) )
        using ( FileStream fs = new FileStream( "g2pa_ENG.dll", FileMode.Open, FileAccess.Read ) ) {
            string sb = "";
            int buflen = 1024;
            byte[] buf = new byte[buflen];
            fs.Seek( 0x12c82, SeekOrigin.Begin );
            while ( true ) {
                int len = fs.Read( buf, 0, buflen );
                if ( len <= 0 ) {
                    break;
                }
                for ( int i = 0; i < len; i++ ) {
                    if ( 0x20 <= buf[i] && buf[i] <= 0x7e ){
                    }else{
                        buf[i] = 0x0A;
                    }
                }
                sw.Write( buf, 0, len );
            }
        }
        using( StreamReader tmp = new StreamReader( tfile ) )
        using( StreamWriter sw = new StreamWriter( file ) ){
            string line = "";
            while( (line = tmp.ReadLine()) != null ){
                if( line == "" ){
                    continue;
                }
                sw.WriteLine( line );
            }
        }
    }
}