Pointwise Plugin SDK
pwpPlatform.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Pointwise Plugin cross platform functions
4  *
5  * Proprietary software product of Pointwise, Inc.
6  * Copyright (c) 1995-2018 Pointwise, Inc.
7  * All rights reserved.
8  *
9  ***************************************************************************/
10 
11 #ifndef _PWPPLATFORM_H_
12 #define _PWPPLATFORM_H_
13 
14 #include <stdio.h>
15 
16 // defines memory management functions malloc/calloc/free
17 #if defined(WINDOWS)
18 # include <malloc.h>
19 #else
20 # include <stdlib.h>
21 #endif /* WINDOWS */
22 
23 
24 extern "C" {
25 
38 /*-----------------------------------------------------*/
45 #if defined(WINDOWS)
46 # define sysEOF EOF
47  typedef fpos_t sysFILEPOS;
48 
49 #else /* *nix or mac */
50 # include <unistd.h>
51 # include <stddef.h>
52 # define sysEOF EOF
53  typedef fpos_t sysFILEPOS;
54 
55 #endif /* WINDOWS */
56 
57 
62 typedef enum sysFILEMODE_e {
63  // base flags.
64  // do not use these directly.
66  pwpRead_ = 0x01,
67  pwpWrite_ = 0x02,
68  pwpAppend_ = 0x04,
69  pwpPlus_ = 0x08,
70 
71  pwpMaskBase_ = 0x0F,
72  pwpMaskFormat_ = 0xF0, // sdkINTERNALS
74 
75  // combine one of these modes:
77  pwpRead = pwpRead_,
79  pwpWrite = pwpWrite_,
81  pwpAppend = pwpAppend_,
83  pwpRWExists = (pwpRead_ | pwpPlus_),
85  pwpRWTruncate = (pwpWrite_ | pwpPlus_),
87  pwpReadAppend = (pwpAppend_ | pwpPlus_),
88 
89  // with one of these formats:
91  pwpBinary = 0x10,
93  pwpFormatted = 0x20,
97  pwpAscii = 0x80
98 }
100 
101 
102 /*---------------------------------------------------------*/
116 FILE *
117 pwpFileOpen (const char *filename, int mode);
118 
119 
120 /*---------------------------------------------------------*/
130 int
131 pwpFileClose (FILE *fp);
132 
133 
134 /*---------------------------------------------------------*/
142 int
143 pwpFileEof (FILE *fp);
144 
145 
146 /*---------------------------------------------------------*/
154 int
155 pwpFileFlush (FILE *fp);
156 
157 
158 /*---------------------------------------------------------*/
171 int
172 pwpFileGetpos (FILE *fp, sysFILEPOS *pos);
173 
174 
175 /*---------------------------------------------------------*/
188 int
189 pwpFileSetpos (FILE *fp, const sysFILEPOS *pos);
190 
191 
192 /*---------------------------------------------------------*/
203 int
204 pwpFileGetSize(FILE *fp, size_t *size);
205 
206 
207 /*---------------------------------------------------------*/
218 int
219 pwpFilenameGetSize(const char *filename, size_t *size);
220 
221 
222 /*---------------------------------------------------------*/
239 size_t
240 pwpFileRead (void *buf, size_t size, size_t count, FILE *fp);
241 
242 
243 /*---------------------------------------------------------*/
260 size_t
261 pwpFileWrite (const void *buf, size_t size, size_t count, FILE *fp);
262 
263 
264 /*---------------------------------------------------------*/
275 size_t
276 pwpFileWriteStr (const char *str, FILE *fp);
277 
278 
279 /*---------------------------------------------------------*/
287 void
288 pwpFileRewind (FILE *fp);
289 
290 
291 /*---------------------------------------------------------*/
297 int
298 pwpFileDelete (const char *filename);
299 
300 
301 /*---------------------------------------------------------*/
314 int
315 pwpCwdPush (const char *dir);
316 
317 
318 /*---------------------------------------------------------*/
327 int
328 pwpCwdPop (void);
329 
330 
331 } /* extern "C" */
332 
333 #endif /* _PWPPLATFORM_H_ */
int pwpFileSetpos(FILE *fp, const sysFILEPOS *pos)
Set the current file position.
int pwpFileClose(FILE *fp)
Closes a file opened with pwpFileOpen().
sysFILEMODE
Bit flags used for pwpFileOpen(mode)
Definition: pwpPlatform.h:62
int pwpFileGetpos(FILE *fp, sysFILEPOS *pos)
Query the current file position.
size_t pwpFileRead(void *buf, size_t size, size_t count, FILE *fp)
Read an collection of data items from a file.
int pwpFilenameGetSize(const char *filename, size_t *size)
Get the file&#39;s size in bytes.
fpos_t sysFILEPOS
File position data type.
Definition: pwpPlatform.h:53
int pwpFileGetSize(FILE *fp, size_t *size)
Get the file&#39;s size in bytes.
int pwpFileDelete(const char *filename)
Delete a file.
size_t pwpFileWrite(const void *buf, size_t size, size_t count, FILE *fp)
Write an collection of data items to a file.
int pwpCwdPush(const char *dir)
Change the current directory.
int pwpFileFlush(FILE *fp)
Flush a file to disk.
FILE * pwpFileOpen(const char *filename, int mode)
Opens a file for I/O.
int pwpCwdPop(void)
Restore the current directory.
void pwpFileRewind(FILE *fp)
Reset position to the beginning of the file.
int pwpFileEof(FILE *fp)
Queries end-of-file status.
size_t pwpFileWriteStr(const char *str, FILE *fp)
Write a null-terminated string to a file.