source: cpp/common/nonstd_stdio.h @ 257

Last change on this file since 257 was 247, checked in by Maciej Komosinski, 9 years ago

Sources support both 32-bit and 64-bit, and more compilers

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#ifndef _NONSTD_STDIO_H_
6#define _NONSTD_STDIO_H_
7
8bool fileExists(const char* path);
9bool directoryExists(const char* path);
10bool makeDirectory(const char* path);
11bool makeDirectories(const char* path);
12bool removeFile(const char* path);
13bool isAbsolutePath(const char* fname);
14int getFileSize(const char* path);
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.?
30// #define makeDirectory(name) mkdir(name)
31#endif
32
33 #define S_ISDIR(x) ((x & _S_IFDIR)==_S_IFDIR)
34
35#else
36
37 #include <unistd.h>
38 #include <sys/stat.h>
39// #define makeDirectory(name) mkdir(name,0777)
40 #define _unlink unlink //_unlink jest ISO-conformant, unlink jest POSIX-deprecated
41 #define _stat stat
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
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
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
67MFILE *mfopen(const char*path,const char*mode);
68void mfclose(MFILE *f);
69int mfread(void *ptr, int size, int n, MFILE *f);
70int mfwrite(const void *ptr, int size, int n, MFILE *f);
71int mfputs(const char *, MFILE *);
72int     mfseek(MFILE *, long, int);
73long mftell(MFILE *);
74char *mfgets(char *str, int num, MFILE *f);
75int 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
102int getFileSize(MFILE *f);
103
104#endif
Note: See TracBrowser for help on using the repository browser.