OSDN Git Service

インストーラーのパスを変更した
[fooeditengine/FooEditEngine.git] / Common / WinFileStream.cs
1 using System;
2 using System.Text;
3 using System.IO;
4 using System.Threading.Tasks;
5
6 namespace FooEditEngine
7 {
8     class WinFileWriter : IStreamWriter
9     {
10         StreamWriter sw;
11
12 #if !METRO
13         public WinFileWriter(string filepath,Encoding enc)
14         {
15             this.sw = new StreamWriter(filepath,false, enc);
16         }
17 #else
18         public WinFileWriter(StreamWriter sw)
19         {
20             this.sw = sw;
21         }
22 #endif
23         
24         public Task WriteAsync(string str)
25         {
26             return this.sw.WriteAsync(str);
27         }
28
29         public string NewLine
30         {
31             get
32             {
33                 return this.sw.NewLine;
34             }
35             set
36             {
37                 this.sw.NewLine = value;
38             }
39         }
40
41         public void Close()
42         {
43 #if !METRO
44             this.sw.Close();
45 #else
46 #endif
47         }
48     }
49     class WinFileReader : IStreamReader
50     {
51         TextReader sr;
52 #if !METRO
53         public WinFileReader(string filepath, Encoding enc)
54         {
55             this.sr = new StreamReader(filepath, enc);
56         }
57         public WinFileReader(TextReader tr)
58         {
59             this.sr = tr;
60         }
61 #else
62         public WinFileReader(StreamReader sr)
63         {
64             this.sr = sr;
65         }
66 #endif
67
68         public bool IsEnd()
69         {
70             return this.sr.Peek() == -1;
71         }
72
73         public Task<string> ReadLineAsync()
74         {
75             return this.sr.ReadLineAsync();
76         }
77
78         public Task<int> ReadAsync(char[] buffer,int index, int count)
79         {
80             return this.sr.ReadAsync(buffer, index, count);
81         }
82
83
84         public void Close()
85         {
86 #if !METRO
87             this.sr.Close();
88 #else
89 #endif
90         }
91     }
92 }