1 /*******************************************************************************
2 
3         copyright:      Copyright (c) 2007 Kris Bell. All rights reserved
4 
5         license:        BSD style: $(LICENSE)
6 
7         version:        Initial release: Nov 2007
8 
9         author:         Kris
10 
11 *******************************************************************************/
12 
13 module tango.io.stream.TextFile;
14 
15 public  import tango.io.device.File;
16 
17 private import tango.io.stream.Text;
18 
19 /*******************************************************************************
20 
21         Composes a file with line-oriented input. The input is buffered.
22 
23 *******************************************************************************/
24 
25 class TextFileInput : TextInput
26 {
27         /***********************************************************************
28 
29                 Compose a FileStream.
30 
31         ***********************************************************************/
32 
33         this (const(char)[] path, File.Style style = File.ReadExisting)
34         {
35                 this (new File (path, style));
36         }
37 
38         /***********************************************************************
39 
40                 Wrap a FileConduit instance.
41 
42         ***********************************************************************/
43 
44         this (File file)
45         {
46                 super (file);
47         }
48 }
49 
50 
51 /*******************************************************************************
52 
53         Composes a file with formatted text output. Output is buffered.
54 
55 *******************************************************************************/
56 
57 class TextFileOutput : TextOutput
58 {
59         /***********************************************************************
60 
61                 Compose a FileStream.
62 
63         ***********************************************************************/
64 
65         this (const(char)[] path, File.Style style = File.WriteCreate)
66         {
67                 this (new File (path, style));
68         }
69 
70         /***********************************************************************
71 
72                 Wrap a File instance.
73 
74         ***********************************************************************/
75 
76         this (File file)
77         {
78                 super (file);
79         }
80  }
81 
82 
83 /*******************************************************************************
84 
85 *******************************************************************************/
86 
87 debug (TextFile)
88 {
89         import tango.io.Console;
90 
91         void main()
92         {
93                 auto t = new TextFileInput ("TextFile.d");
94                 foreach (line; t)
95                          Cout(line).newline;
96         }
97 }