[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
| 2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
| 3 | // See LICENSE.txt for details. |
---|
[122] | 4 | |
---|
[109] | 5 | #ifndef _NONSTD_STDIO_H_ |
---|
| 6 | #define _NONSTD_STDIO_H_ |
---|
| 7 | |
---|
| 8 | bool fileExists(const char* path); |
---|
[295] | 9 | bool directoryExists(const char* path,bool is_writable); |
---|
[247] | 10 | bool makeDirectory(const char* path); |
---|
| 11 | bool makeDirectories(const char* path); |
---|
[109] | 12 | bool removeFile(const char* path); |
---|
[201] | 13 | bool isAbsolutePath(const char* fname); |
---|
[247] | 14 | int getFileSize(const char* path); |
---|
[109] | 15 | |
---|
| 16 | #ifdef _WIN32 |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #ifndef _MSC_VER |
---|
| 20 | #include <dir.h> |
---|
| 21 | #else |
---|
| 22 | #include <direct.h> |
---|
| 23 | #define mkdir _mkdir |
---|
[281] | 24 | #define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR) |
---|
[109] | 25 | #endif |
---|
| 26 | |
---|
[281] | 27 | #include <io.h> //borland compiler: include <io.h> before <dir.h> causes the SimWorld class in "simul.h" be unrecognized, for unknown reason :O moreover, this problem is only pertinent to the CLI project, not GUI. Maybe this is caused by global defines like NOVCL, NO_STRICT etc.? |
---|
[247] | 28 | // #define makeDirectory(name) mkdir(name) |
---|
[109] | 29 | |
---|
| 30 | #else |
---|
| 31 | |
---|
[281] | 32 | #include <unistd.h> |
---|
| 33 | #include <sys/stat.h> |
---|
[247] | 34 | // #define makeDirectory(name) mkdir(name,0777) |
---|
[281] | 35 | #define _unlink unlink //_unlink jest ISO-conformant, unlink jest POSIX-deprecated |
---|
| 36 | #define _stat stat |
---|
[109] | 37 | #endif |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | #include <stdio.h> |
---|
| 41 | |
---|
| 42 | #if (defined SHP && defined BADA_API_1) || defined __ANDROID__ |
---|
| 43 | |
---|
| 44 | #ifdef __ANDROID__ |
---|
| 45 | #include <nv_file/nv_file.h> |
---|
[281] | 46 | struct rwFILE //jedno z dwoch pol jest zainicjowane w zaleznosci od tego gdzie jest plik |
---|
| 47 | { //nvidia uses a similar trick in nv_file.h (STD_FILE and APK_FILE), maybe doing a similar thing here is redundant? but their trick uses some trial-and-error code (see NvFOpen()) |
---|
[227] | 48 | NvFile *rfile; //can only read |
---|
[109] | 49 | FILE *rwfile; |
---|
| 50 | rwFILE() {rfile=rwfile=NULL;} |
---|
[281] | 51 | }; |
---|
| 52 | typedef rwFILE MFILE; |
---|
[109] | 53 | #else //SHP: |
---|
[281] | 54 | //z <stdio.h> wzielismy sprintfy i inne ktore dzia³aj¹... |
---|
| 55 | #include <FIo.h> |
---|
| 56 | // wklejone z sailora w ramach integracji frams+engine |
---|
| 57 | // ale to nie sprawia ze framsy korzystaja z mfile - potrzebna jest implementacja virtfile dla bady! (patrz: stdiofile.h) |
---|
| 58 | // i wtedy bedzie mozna mfile wywalic tez z sailora |
---|
| 59 | typedef Osp::Io::File MFILE; |
---|
[109] | 60 | #endif |
---|
| 61 | |
---|
| 62 | MFILE *mfopen(const char*path,const char*mode); |
---|
| 63 | void mfclose(MFILE *f); |
---|
| 64 | int mfread(void *ptr, int size, int n, MFILE *f); |
---|
| 65 | int mfwrite(const void *ptr, int size, int n, MFILE *f); |
---|
| 66 | int mfputs(const char *, MFILE *); |
---|
| 67 | int mfseek(MFILE *, long, int); |
---|
| 68 | long mftell(MFILE *); |
---|
| 69 | char *mfgets(char *str, int num, MFILE *f); |
---|
| 70 | int mfeof(MFILE *f); |
---|
| 71 | |
---|
| 72 | //#define SEEK_SET 0 /* set file offset to offset */ |
---|
| 73 | //#define SEEK_CUR 1 /* set file offset to current plus offset */ |
---|
| 74 | //#define SEEK_END 2 /* set file offset to EOF plus offset */ |
---|
| 75 | //int sprintf(char *, const char *, ...); |
---|
| 76 | //int vsnprintf(char *,int, const char *, ...); |
---|
| 77 | |
---|
| 78 | #else |
---|
[281] | 79 | typedef FILE MFILE; |
---|
| 80 | #ifdef _WIN32 |
---|
| 81 | #define mfopen _wfopen |
---|
| 82 | #else |
---|
[109] | 83 | #define mfopen fopen |
---|
| 84 | #endif |
---|
[281] | 85 | #define mfclose fclose |
---|
| 86 | #define mfread fread |
---|
| 87 | #define mfwrite fwrite |
---|
| 88 | #define mfputs fputs |
---|
| 89 | #define mfgets fgets |
---|
| 90 | #define mfeof feof |
---|
| 91 | #define mfseek fseek |
---|
| 92 | #define mftell ftell |
---|
| 93 | #endif |
---|
[109] | 94 | |
---|
| 95 | |
---|
| 96 | #ifndef _WIN32 |
---|
| 97 | #define _strdup strdup //_strdup jest ISO-conformant, strdup jest POSIX deprecated |
---|
| 98 | #include <string.h> //strdup |
---|
| 99 | #endif |
---|
| 100 | |
---|
[247] | 101 | int getFileSize(MFILE *f); |
---|
| 102 | |
---|
[109] | 103 | #endif |
---|