1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius*   Copyright (C) 1997-2011, International Business Machines
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File FILESTRM.C
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* @author       Glenn Marcy
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Modification History:
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Date        Name        Description
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   5/8/98      gm          Created
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*  03/02/99     stephen     Reordered params in ungetc to match stdio
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*                           Added wopen
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   3/29/99     helena      Merged Stephen and Bertrand's changes.
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "filestrm.h"
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "cmemory.h"
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdio.h>
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI FileStream* U_EXPORT2
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_open(const char* filename, const char* mode)
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(filename != NULL && *filename != 0 && mode != NULL && *mode != 0) {
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        FILE *file = fopen(filename, mode);
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return (FileStream*)file;
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } else {
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return NULL;
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI FileStream* U_EXPORT2
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_wopen(const wchar_t* filename, const wchar_t* mode)
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   // TBD: _wfopen is believed to be MS-specific?
4683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#if U_PLATFORM_USES_ONLY_WIN32_API
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FILE* result = _wfopen(filename, mode);
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (FileStream*)result;
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    size_t fnMbsSize, mdMbsSize;
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    char *fn, *md;
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FILE *result;
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // convert from wchar_t to char
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fnMbsSize = wcstombs(NULL, filename, ((size_t)-1) >> 1);
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fn = (char*)uprv_malloc(fnMbsSize+2);
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    wcstombs(fn, filename, fnMbsSize);
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fn[fnMbsSize] = 0;
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    mdMbsSize = wcstombs(NULL, mode, ((size_t)-1) >> 1);
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    md = (char*)uprv_malloc(mdMbsSize+2);
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    wcstombs(md, mode, mdMbsSize);
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    md[mdMbsSize] = 0;
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    result = fopen(fn, md);
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    uprv_free(fn);
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    uprv_free(md);
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (FileStream*)result;
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI void U_EXPORT2
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_close(FileStream* fileStream)
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (fileStream != 0)
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        fclose((FILE*)fileStream);
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_file_exists(const char* filename)
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FILE* temp = fopen(filename, "r");
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (temp) {
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        fclose(temp);
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return TRUE;
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } else
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return FALSE;
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*static const int32_t kEOF;
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst int32_t FileStream::kEOF = EOF;*/
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI FileStream*
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_tmpfile()
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FILE* file = tmpfile();
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (FileStream*)file;
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_read(FileStream* fileStream, void* addr, int32_t len)
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fread(addr, 1, len, (FILE*)fileStream);
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_write(FileStream* fileStream, const void* addr, int32_t len)
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fwrite(addr, 1, len, (FILE*)fileStream);
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI void U_EXPORT2
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_rewind(FileStream* fileStream)
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    rewind((FILE*)fileStream);
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_putc(FileStream* fileStream, int32_t ch)
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t c = fputc(ch, (FILE*)fileStream);
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return c;
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int U_EXPORT2
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_getc(FileStream* fileStream)
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int c = fgetc((FILE*)fileStream);
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return c;
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_ungetc(int32_t ch, FileStream* fileStream)
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t c = ungetc(ch, (FILE*)fileStream);
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return c;
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_peek(FileStream* fileStream)
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t c = fgetc((FILE*)fileStream);
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return ungetc(c, (FILE*)fileStream);
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char* U_EXPORT2
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_readLine(FileStream* fileStream, char* buffer, int32_t length)
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fgets(buffer, length, (FILE*)fileStream);
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_writeLine(FileStream* fileStream, const char* buffer)
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return fputs(buffer, (FILE*)fileStream);
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_size(FileStream* fileStream)
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t savedPos = ftell((FILE*)fileStream);
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t size = 0;
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*Changes by Bertrand A. D. doesn't affect the current position
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    goes to the end of the file before ftell*/
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fseek((FILE*)fileStream, 0, SEEK_END);
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    size = (int32_t)ftell((FILE*)fileStream);
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fseek((FILE*)fileStream, savedPos, SEEK_SET);
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return size;
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int U_EXPORT2
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_eof(FileStream* fileStream)
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return feof((FILE*)fileStream);
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Warning
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru This function may not work consistently on all platforms
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru (e.g. HP-UX, FreeBSD and MacOSX don't return an error when
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru putc is used on a file opened as readonly)
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int U_EXPORT2
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_error(FileStream* fileStream)
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (fileStream == 0 || ferror((FILE*)fileStream));
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* This function doesn't work. */
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* force the stream to set its error flag*/
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*U_CAPI void U_EXPORT2
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_setError(FileStream* fileStream)
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    fseek((FILE*)fileStream, 99999, SEEK_SET);
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI FileStream* U_EXPORT2
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_stdin(void)
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (FileStream*)stdin;
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI FileStream* U_EXPORT2
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_stdout(void)
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (FileStream*)stdout;
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI FileStream* U_EXPORT2
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_stderr(void)
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (FileStream*)stderr;
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI UBool U_EXPORT2
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_FileStream_remove(const char* fileName){
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return (remove(fileName) == 0);
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
226