| 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. |
|---|
| 4 | |
|---|
| 5 | #ifndef _NONSTD_STDIO_H_ |
|---|
| 6 | #define _NONSTD_STDIO_H_ |
|---|
| 7 | |
|---|
| 8 | bool fileExists(const char* path); |
|---|
| 9 | bool directoryExists(const char* path,bool is_writable); |
|---|
| 10 | bool makeDirectory(const char* path); |
|---|
| 11 | bool makeDirectories(const char* path); |
|---|
| 12 | bool removeFile(const char* path); |
|---|
| 13 | bool isAbsolutePath(const char* fname); |
|---|
| 14 | int getFileSize(const char* path); |
|---|
| 15 | |
|---|
| 16 | #ifdef _WIN32 |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #ifndef _MSC_VER |
|---|
| 20 | #include <dir.h> |
|---|
| 21 | #else |
|---|
| 22 | #include <direct.h> |
|---|
| 23 | #define mkdir _mkdir |
|---|
| 24 | #define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR) |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 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.? |
|---|
| 28 | // #define makeDirectory(name) mkdir(name) |
|---|
| 29 | |
|---|
| 30 | #else |
|---|
| 31 | |
|---|
| 32 | #include <unistd.h> |
|---|
| 33 | #include <sys/stat.h> |
|---|
| 34 | // #define makeDirectory(name) mkdir(name,0777) |
|---|
| 35 | #define _unlink unlink //_unlink jest ISO-conformant, unlink jest POSIX-deprecated |
|---|
| 36 | #define _stat stat |
|---|
| 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> |
|---|
| 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()) |
|---|
| 48 | NvFile *rfile; //can only read |
|---|
| 49 | FILE *rwfile; |
|---|
| 50 | rwFILE() {rfile=rwfile=NULL;} |
|---|
| 51 | }; |
|---|
| 52 | typedef rwFILE MFILE; |
|---|
| 53 | #else //SHP: |
|---|
| 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; |
|---|
| 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 |
|---|
| 79 | typedef FILE MFILE; |
|---|
| 80 | #ifdef _WIN32 |
|---|
| 81 | FILE* mfile_wfopen(const char *path, const char *mode); |
|---|
| 82 | #define mfopen mfile_wfopen |
|---|
| 83 | #else |
|---|
| 84 | #define mfopen fopen |
|---|
| 85 | #endif |
|---|
| 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 | |
|---|
| 102 | int getFileSize(MFILE *f); |
|---|
| 103 | |
|---|
| 104 | #endif |
|---|