[122] | 1 | // This file is a part of the Framsticks GDK. |
---|
[197] | 2 | // Copyright (C) 1999-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. |
---|
[122] | 3 | // Refer to http://www.framsticks.com/ for further information. |
---|
| 4 | |
---|
[109] | 5 | #ifndef _NONSTD_STDIO_H_ |
---|
| 6 | #define _NONSTD_STDIO_H_ |
---|
| 7 | |
---|
| 8 | bool fileExists(const char* path); |
---|
[247] | 9 | bool directoryExists(const char* path); |
---|
| 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 | #ifndef MOBILE2D |
---|
| 23 | #include <direct.h> |
---|
| 24 | #endif |
---|
| 25 | #define mkdir _mkdir |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | #ifndef MOBILE2D |
---|
| 29 | #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] | 30 | // #define makeDirectory(name) mkdir(name) |
---|
[109] | 31 | #endif |
---|
| 32 | |
---|
[247] | 33 | #define S_ISDIR(x) ((x & _S_IFDIR)==_S_IFDIR) |
---|
[109] | 34 | |
---|
| 35 | #else |
---|
| 36 | |
---|
| 37 | #include <unistd.h> |
---|
| 38 | #include <sys/stat.h> |
---|
[247] | 39 | // #define makeDirectory(name) mkdir(name,0777) |
---|
[109] | 40 | #define _unlink unlink //_unlink jest ISO-conformant, unlink jest POSIX-deprecated |
---|
[247] | 41 | #define _stat stat |
---|
[109] | 42 | #endif |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | #include <stdio.h> |
---|
| 46 | |
---|
| 47 | #if (defined SHP && defined BADA_API_1) || defined __ANDROID__ |
---|
| 48 | |
---|
| 49 | #ifdef __ANDROID__ |
---|
| 50 | #include <nv_file/nv_file.h> |
---|
| 51 | struct rwFILE //jedno z dwoch pol jest zainicjowane w zaleznosci od tego gdzie jest plik |
---|
[227] | 52 | { //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()) |
---|
| 53 | NvFile *rfile; //can only read |
---|
[109] | 54 | FILE *rwfile; |
---|
| 55 | rwFILE() {rfile=rwfile=NULL;} |
---|
| 56 | }; |
---|
| 57 | typedef rwFILE MFILE; |
---|
| 58 | #else //SHP: |
---|
| 59 | //z <stdio.h> wzielismy sprintfy i inne ktore dzia³aj¹... |
---|
| 60 | #include <FIo.h> |
---|
| 61 | // wklejone z sailora w ramach integracji frams+engine |
---|
| 62 | // ale to nie sprawia ze framsy korzystaja z mfile - potrzebna jest implementacja virtfile dla bady! (patrz: stdiofile.h) |
---|
| 63 | // i wtedy bedzie mozna mfile wywalic tez z sailora |
---|
| 64 | typedef Osp::Io::File MFILE; |
---|
| 65 | #endif |
---|
| 66 | |
---|
| 67 | MFILE *mfopen(const char*path,const char*mode); |
---|
| 68 | void mfclose(MFILE *f); |
---|
| 69 | int mfread(void *ptr, int size, int n, MFILE *f); |
---|
| 70 | int mfwrite(const void *ptr, int size, int n, MFILE *f); |
---|
| 71 | int mfputs(const char *, MFILE *); |
---|
| 72 | int mfseek(MFILE *, long, int); |
---|
| 73 | long mftell(MFILE *); |
---|
| 74 | char *mfgets(char *str, int num, MFILE *f); |
---|
| 75 | int mfeof(MFILE *f); |
---|
| 76 | |
---|
| 77 | //#define SEEK_SET 0 /* set file offset to offset */ |
---|
| 78 | //#define SEEK_CUR 1 /* set file offset to current plus offset */ |
---|
| 79 | //#define SEEK_END 2 /* set file offset to EOF plus offset */ |
---|
| 80 | //int sprintf(char *, const char *, ...); |
---|
| 81 | //int vsnprintf(char *,int, const char *, ...); |
---|
| 82 | |
---|
| 83 | #else |
---|
| 84 | typedef FILE MFILE; |
---|
| 85 | #define mfopen fopen |
---|
| 86 | #define mfclose fclose |
---|
| 87 | #define mfread fread |
---|
| 88 | #define mfwrite fwrite |
---|
| 89 | #define mfputs fputs |
---|
| 90 | #define mfgets fgets |
---|
| 91 | #define mfeof feof |
---|
| 92 | #define mfseek fseek |
---|
| 93 | #define mftell ftell |
---|
| 94 | #endif |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | #ifndef _WIN32 |
---|
| 98 | #define _strdup strdup //_strdup jest ISO-conformant, strdup jest POSIX deprecated |
---|
| 99 | #include <string.h> //strdup |
---|
| 100 | #endif |
---|
| 101 | |
---|
[247] | 102 | int getFileSize(MFILE *f); |
---|
| 103 | |
---|
[109] | 104 | #endif |
---|