00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _PORTSTREAM_H_
00023 #define _PORTSTREAM_H_
00024
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029
00030 #include <stdio.h>
00031 #include "ptypes.h"
00032
00033 #ifdef PFILE_VIRTUAL_SUPPORT
00034
00035 struct FileBufferFrame;
00036 typedef struct PORT_FILE_HANDLE
00037 {
00038 const char *filename;
00039 struct FileBufferFrame *startFrame;
00040 struct FileBufferFrame *endFrame;
00041 struct FileBufferFrame *curFrame;
00042 const unsigned char *curPos;
00043 const unsigned char *endPos;
00044 unsigned int size;
00045 unsigned int frame_size;
00046 int eof;
00047 int mode;
00048 }
00049 PORT_FILE_HANDLE;
00050
00051 typedef PORT_FILE_HANDLE* PORT_FILE;
00052
00053 typedef struct _FileRecord
00054 {
00055 char name[80];
00056 unsigned char *start;
00057 int end;
00058 int size;
00059 int mode;
00060 }
00061 FileRecord;
00062
00063 typedef struct VirtualFileTable_t
00064 {
00065 const FileRecord* pFileTable;
00066 const unsigned char* pFirstFile;
00067 }
00068 VirtualFileTable;
00069
00070
00071 PORTABLE_API void PortFileInit(void);
00072 PORTABLE_API PORT_FILE PortFopen(const char* filename, const char* mode);
00073 PORTABLE_API int PortFclose(PORT_FILE PortFile);
00074 PORTABLE_API size_t PortFread(void* buffer, size_t size, size_t count, PORT_FILE PortFile);
00075 PORTABLE_API size_t PortFwrite(const void* buffer, size_t size, size_t count, PORT_FILE PortFile);
00076 PORTABLE_API int PortFseek(PORT_FILE PortFile, long offset, int origin);
00077 PORTABLE_API long PortFtell(PORT_FILE PortFile);
00078 PORTABLE_API int PortFprintf(PORT_FILE PortFile, const char* format, ...);
00079 PORTABLE_API char* PortFgets(char* string, int n, PORT_FILE PortFile);
00080 PORTABLE_API int PortFflush(PORT_FILE PortFile);
00081 PORTABLE_API int PortFeof(PORT_FILE PortFile);
00082 PORTABLE_API int PortFgetc(PORT_FILE PortFile);
00083 PORTABLE_API int PortFscanf(PORT_FILE PortFile, const char *format, ...);
00084 PORTABLE_API int PortFerror(PORT_FILE PortFile);
00085 PORTABLE_API void PortClearerr(PORT_FILE PortFile);
00086 PORTABLE_API void PortRewind(PORT_FILE PortFile);
00087 PORTABLE_API PORT_FILE PortFreopen(const char *path, const char *mode, PORT_FILE PortFile);
00088 PORTABLE_API char* PortGetcwd(char *buffer, int maxlen);
00089 PORTABLE_API int PortMkdir(const char *dirname);
00090
00091
00092 PORTABLE_API int PortFcreate(const char *fname, void *pBuffer, int size);
00093 PORTABLE_API void PortFdelete(const char *fname);
00094
00095 PORTABLE_API void PortSetFileTable(const FileRecord* pFileTable, const unsigned char* pFirstFile);
00096
00097 void SetFileTable(VirtualFileTable *table);
00098
00099 #endif
00100
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104
00105 #endif