source: cpp/common/nonstd_stdio.h @ 907

Last change on this file since 907 was 374, checked in by Maciej Komosinski, 10 years ago

Under _WIN32, mfopen() now redirects to a function mfile_wfopen() that converts arguments to wide char and then uses _wfopen()

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
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
8bool fileExists(const char* path);
9bool directoryExists(const char* path,bool is_writable);
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 #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>
46struct 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};
52typedef 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
59typedef Osp::Io::File MFILE;
60#endif
61
62MFILE *mfopen(const char*path,const char*mode);
63void mfclose(MFILE *f);
64int mfread(void *ptr, int size, int n, MFILE *f);
65int mfwrite(const void *ptr, int size, int n, MFILE *f);
66int mfputs(const char *, MFILE *);
67int     mfseek(MFILE *, long, int);
68long mftell(MFILE *);
69char *mfgets(char *str, int num, MFILE *f);
70int 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
79typedef 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
102int getFileSize(MFILE *f);
103
104#endif
Note: See TracBrowser for help on using the repository browser.