source: cpp/common/nonstd_stdio.h @ 371

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

Reorganizations and extensions of directory/file/filesystem IO classes

  • Property svn:eol-style set to native
File size: 3.0 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 #define mfopen _wfopen
82#else
83 #define mfopen fopen
84#endif
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
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
101int getFileSize(MFILE *f);
102
103#endif
Note: See TracBrowser for help on using the repository browser.