source: trunk/src/odincrt/file.cpp@ 2178

Last change on this file since 2178 was 2178, checked in by sandervl, 26 years ago

wrappers for file io functions to prevent FS corruption

File size: 3.4 KB
Line 
1/* $Id: file.cpp,v 1.1 1999-12-21 12:28:07 sandervl Exp $ */
2/*
3 * Project Odin Software License can be found in LICENSE.TXT
4 * strncpy replacement (one in RTL lib is buggy; doesn't stop at 0 terminator)
5 *
6 * Copyright 1999 Sander van Leeuwen
7 * Copyright 1999 Patrick Haller
8 *
9 */
10#include <stdio.h>
11#include <os2sel.h>
12#include <wchar.h>
13
14int _LNK_CONV os2_fclose( FILE *fp )
15{
16 unsigned short sel = RestoreOS2FS();
17 int rc;
18
19 rc = fclose(fp);
20 return rc;
21}
22
23int _LNK_CONV os2_feof( FILE *fp )
24{
25 unsigned short sel = RestoreOS2FS();
26 int rc;
27
28 rc = feof(fp);
29 return rc;
30}
31int _LNK_CONV os2_ferror( FILE *fp )
32{
33 unsigned short sel = RestoreOS2FS();
34 int rc;
35
36 rc = ferror(fp);
37 return rc;
38}
39int _LNK_CONV os2_fflush( FILE *fp )
40{
41 unsigned short sel = RestoreOS2FS();
42 int rc;
43
44 rc = fflush(fp);
45 return rc;
46}
47int _LNK_CONV os2_fgetc( FILE *fp )
48{
49 unsigned short sel = RestoreOS2FS();
50 int rc;
51
52 rc = fgetc(fp);
53 return rc;
54}
55int _LNK_CONV os2_fgetpos( FILE *fp, fpos_t *pos)
56{
57 unsigned short sel = RestoreOS2FS();
58 int rc;
59
60 rc = fgetpos(fp,pos);
61 return rc;
62}
63char *_LNK_CONV os2_fgets( char *buf, int size, FILE *fp )
64{
65 unsigned short sel = RestoreOS2FS();
66 char * rc;
67
68 rc = fgets(buf, size, fp);
69 return rc;
70}
71FILE * _LNK_CONV os2_fopen( const char *name, const char *type)
72{
73 unsigned short sel = RestoreOS2FS();
74 FILE * rc;
75
76 rc = fopen(name, type);
77 return rc;
78}
79int _LNK_CONV os2_fputc( int c, FILE *fp )
80{
81 unsigned short sel = RestoreOS2FS();
82 int rc;
83
84 rc = fputc(c, fp);
85 return rc;
86}
87int _LNK_CONV os2_fputs( const char *string, FILE *fp )
88{
89 unsigned short sel = RestoreOS2FS();
90 int rc;
91
92 rc = fputs(string, fp);
93 return rc;
94}
95size_t _LNK_CONV os2_fread( void *buf, size_t size, size_t elsize, FILE *fp )
96{
97 unsigned short sel = RestoreOS2FS();
98 size_t rc;
99
100 rc = fread(buf, size, elsize, fp);
101 return rc;
102}
103FILE * _LNK_CONV os2_freopen( const char *name, const char *type, FILE *fp )
104{
105 unsigned short sel = RestoreOS2FS();
106 FILE * rc;
107
108 rc = freopen(name, type, fp);
109 return rc;
110}
111int _LNK_CONV os2_fseek( FILE *fp, long int pos, int type)
112{
113 unsigned short sel = RestoreOS2FS();
114 int rc;
115
116 rc = fseek(fp, pos, type);
117 return rc;
118}
119int _LNK_CONV os2_fsetpos( FILE *fp, const fpos_t *pos)
120{
121 unsigned short sel = RestoreOS2FS();
122 int rc;
123
124 rc = fsetpos(fp, pos);
125 return rc;
126}
127long int _LNK_CONV os2_ftell( FILE *fp )
128{
129 unsigned short sel = RestoreOS2FS();
130 long rc;
131
132 rc = ftell(fp);
133 return rc;
134}
135size_t _LNK_CONV os2_fwrite( const void *buf, size_t size, size_t elsize, FILE *fp )
136{
137 unsigned short sel = RestoreOS2FS();
138 size_t rc;
139
140 rc = fwrite(buf, size, elsize, fp);
141 return rc;
142}
143int _LNK_CONV os2_vfprintf( FILE *fp, const char *string, __va_list list )
144{
145 unsigned short sel = RestoreOS2FS();
146 int rc;
147
148 rc = vfprintf(fp, string, list);
149 return rc;
150}
151wint_t _LNK_CONV os2_fgetwc(FILE *fp)
152{
153 unsigned short sel = RestoreOS2FS();
154 wint_t rc;
155
156 rc = fgetwc(fp);
157 return rc;
158}
159wchar_t * _LNK_CONV os2_fgetws(wchar_t *buf, int size, FILE *fp)
160{
161 unsigned short sel = RestoreOS2FS();
162 wchar_t * rc;
163
164 rc = fgetws(buf, size, fp);
165 return rc;
166}
167wint_t _LNK_CONV os2_fputwc(wchar_t character, FILE *fp)
168{
169 unsigned short sel = RestoreOS2FS();
170 wint_t rc;
171
172 rc = fputwc(character, fp);
173 return rc;
174}
175int _LNK_CONV os2_fputws(const wchar_t *string, FILE *fp)
176{
177 unsigned short sel = RestoreOS2FS();
178 int rc;
179
180 rc = fputws(string, fp);
181 return rc;
182}
Note: See TracBrowser for help on using the repository browser.