OSDN Git Service

[WIP] Update to upstream 2018-10-05.This still not finish.May cause FTBFS.
[csp-qt/common_source_project-fm7.git] / source / src / fileio.h
index e8153fc..78a6619 100644 (file)
 #ifndef _FILEIO_H_
 #define _FILEIO_H_
 
-#ifdef _USE_AGAR
-#include <agar/core.h>
-#elif defined(_USE_QT)
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#else
-#include <windows.h>
-#endif
 #include <stdio.h>
 #include "common.h"
 
 #define FILEIO_WRITE_ASCII             6
 #define FILEIO_READ_WRITE_ASCII                7
 #define FILEIO_READ_WRITE_NEW_ASCII    8
+#define FILEIO_WRITE_APPEND_ASCII      9
+#define FILEIO_READ_WRITE_APPEND_ASCII 10
 #define FILEIO_SEEK_SET                        0
 #define FILEIO_SEEK_CUR                        1
 #define FILEIO_SEEK_END                        2
 
-class FILEIO
+#ifdef USE_ZLIB
+struct gzFile_s;
+typedef struct gzFile_s *gzFile;
+#endif
+
+class DLL_PREFIX FILEIO
 {
 private:
+#ifdef USE_ZLIB
+       gzFile gz;
+       long gz_size;
+#endif
        FILE* fp;
+       _TCHAR path[_MAX_PATH];
+       int open_mode;
        
 public:
        FILEIO();
        ~FILEIO();
-       static bool IsFileExists(_TCHAR *filename);
-       bool IsProtected(_TCHAR *filename);
-       bool Fopen(_TCHAR *filename, int mode);
+       
+       static bool IsFileExisting(const _TCHAR *file_path);
+       static bool IsFileProtected(const _TCHAR *file_path);
+       static bool RemoveFile(const _TCHAR *file_path);
+       static bool RenameFile(const _TCHAR *existing_file_path, const _TCHAR *new_file_path);
+       
+       bool Fopen(const _TCHAR *file_path, int mode);
+#ifdef USE_ZLIB
+       bool Gzopen(const _TCHAR *file_path, int mode);
+#endif
        void Fclose();
-       bool IsOpened() { return (fp != NULL); }
+       bool IsOpened()
+       {
+#ifdef USE_ZLIB
+               if(gz != NULL) {
+                       return true;
+               } else
+#endif
+               return (fp != NULL);
+       }
+       const _TCHAR *FilePath()
+       {
+               return path;
+       }
+       long FileLength();
        
        bool FgetBool();
        void FputBool(bool val);
-       uint8 FgetUint8();
-       void FputUint8(uint8 val);
-       uint16 FgetUint16();
-       void FputUint16(uint16 val);
-       uint32 FgetUint32();
-       void FputUint32(uint32 val);
-       uint64 FgetUint64();
-       void FputUint64(uint64 val);
-       int8 FgetInt8();
-       void FputInt8(int8 val);
-       int16 FgetInt16();
-       void FputInt16(int16 val);
-       int32 FgetInt32();
-       void FputInt32(int32 val);
-       int64 FgetInt64();
-       void FputInt64(int64 val);
+       uint8_t FgetUint8();
+       void FputUint8(uint8_t val);
+       uint16_t FgetUint16();
+       void FputUint16(uint16_t val);
+       uint32_t FgetUint32();
+       void FputUint32(uint32_t val);
+       uint64_t FgetUint64();
+       void FputUint64(uint64_t val);
+       int8_t FgetInt8();
+       void FputInt8(int8_t val);
+       int16_t FgetInt16();
+       void FputInt16(int16_t val);
+       int32_t FgetInt32();
+       void FputInt32(int32_t val);
+       int64_t FgetInt64();
+       void FputInt64(int64_t val);
        float FgetFloat();
        void FputFloat(float val);
        double FgetDouble();
        void FputDouble(double val);
        
-       uint16 FgetUint16_LE();
-       void FputUint16_LE(uint16 val);
-       uint32 FgetUint32_LE();
-       void FputUint32_LE(uint32 val);
-       uint64 FgetUint64_LE();
-       void FputUint64_LE(uint64 val);
-       int16 FgetInt16_LE();
-       void FputInt16_LE(int16 val);
-       int32 FgetInt32_LE();
-       void FputInt32_LE(int32 val);
-       int64 FgetInt64_LE();
-       void FputInt64_LE(int64 val);
+       uint16_t FgetUint16_LE();
+       void FputUint16_LE(uint16_t val);
+       uint32_t FgetUint32_LE();
+       void FputUint32_LE(uint32_t val);
+       uint64_t FgetUint64_LE();
+       void FputUint64_LE(uint64_t val);
+       int16_t FgetInt16_LE();
+       void FputInt16_LE(int16_t val);
+       int32_t FgetInt32_LE();
+       void FputInt32_LE(int32_t val);
+       int64_t FgetInt64_LE();
+       void FputInt64_LE(int64_t val);
+       float FgetFloat_LE();
+       void FputFloat_LE(float val);
+       double FgetDouble_LE();
+       void FputDouble_LE(double val);
        
-       uint16 FgetUint16_BE();
-       void FputUint16_BE(uint16 val);
-       uint32 FgetUint32_BE();
-       void FputUint32_BE(uint32 val);
-       uint64 FgetUint64_BE();
-       void FputUint64_BE(uint64 val);
-       int16 FgetInt16_BE();
-       void FputInt16_BE(int16 val);
-       int32 FgetInt32_BE();
-       void FputInt32_BE(int32 val);
-       int64 FgetInt64_BE();
-       void FputInt64_BE(int64 val);
+       uint16_t FgetUint16_BE();
+       void FputUint16_BE(uint16_t val);
+       uint32_t FgetUint32_BE();
+       void FputUint32_BE(uint32_t val);
+       uint64_t FgetUint64_BE();
+       void FputUint64_BE(uint64_t val);
+       int16_t FgetInt16_BE();
+       void FputInt16_BE(int16_t val);
+       int32_t FgetInt32_BE();
+       void FputInt32_BE(int32_t val);
+       int64_t FgetInt64_BE();
+       void FputInt64_BE(int64_t val);
+       float FgetFloat_BE();
+       void FputFloat_BE(float val);
+       double FgetDouble_BE();
+       void FputDouble_BE(double val);
        
        int Fgetc();
        int Fputc(int c);
        char *Fgets(char *str, int n);
-       uint32 Fread(void* buffer, uint32 size, uint32 count);
-       uint32 Fwrite(void* buffer, uint32 size, uint32 count);
-       uint32 Fseek(long offset, int origin);
-       uint32 Ftell();
-       static void Remove(_TCHAR *filename);
+       _TCHAR *Fgetts(_TCHAR *str, int n);
+       int Fprintf(const char* format, ...);
+       int Ftprintf(const _TCHAR* format, ...);
+       
+       size_t Fread(void* buffer, size_t size, size_t count);
+       size_t Fwrite(const void* buffer, size_t size, size_t count);
+       int Fseek(long offset, int origin);
+       long Ftell();
+       bool Fcompare(const void* buffer, size_t size);
+       bool Fcompare(const void* buffer, size_t size, size_t count);
+       
+       bool StateCheckUint32(uint32_t val);
+       bool StateCheckInt32(int32_t val);
+       bool StateCheckBuffer(const void *buffer, size_t size, size_t count);
+       
+       void StateBool(bool &val);
+       void StateUint8(uint8_t &val);
+       void StateUint16(uint16_t &val);
+       void StateUint32(uint32_t &val);
+       void StateUint64(uint64_t &val);
+       void StateInt8(int8_t &val);
+       void StateInt16(int16_t &val);
+       void StateInt32(int32_t &val);
+       void StateInt64(int64_t &val);
+       void StateFloat(float &val);
+       void StateDouble(double &val);
+       void StateBuffer(void *buffer, size_t size, size_t count);
 };
 
 #endif