1
/***************************************************************************
3
* This program is free software; you can redistribute it and/or modify *
4
* it under the terms of the GNU Lesser General Public License as *
5
* published by the Free Software Foundation; either version 2 of the *
6
* License, or (at your option) any later version. *
8
***************************************************************************/
10
#include "OgrePagingLandScapePrecompiledHeaders.h"
12
// #include "OgreNoMemoryMacros.h"
15
#include <sys/types.h>
23
//newer mingw has this defined in sys/stat.h
24
# define S_ISDIR(mode) (mode&S_IFDIR)
26
# define STRUCT_STAT struct _stat
28
# define GETCWD _getcwd
29
# define MKDIR(A) _mkdir(A)
30
# define STAT(A,S) _stat(A,S)
34
# include <malloc/malloc.h>
39
# include <sys/param.h>
41
# define MAX_PATH MAXPATHLEN
42
# define STRUCT_STAT struct stat
44
# define GETCWD getcwd
45
# define MKDIR(A) mkdir(A, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)// set mode of directory to drwxr-xr-x.
46
# define STAT(A,S) stat(A,S)
47
#endif //_LINUX _APPLE
49
//-----------------------------------------------------------------------
50
static char* GetCurrDir()
52
// GETCWD MALLOCS A BUFFER. REMEMBER TO FREE IT.
60
//-----------------------------------------------------------------------
61
bool DirExists(const char *Dirname)
65
if (STAT(Dirname, &st))
67
// doesn't exist; must create it
70
if (S_ISDIR(st.st_mode) == 0)
72
// it's not a dir, must create a dir
77
//-----------------------------------------------------------------------
78
char * ChangeToDir (const char *Dirname)
82
if (STAT(Dirname, &st))
84
// doen't exist; must create it
87
if (S_ISDIR(st.st_mode) == 0)
89
// it's not a dir, must create a dir
92
char *oldDirname = GetCurrDir ();
100
void RetablishDir(char *oldDirname)
102
if (oldDirname != NULL)
104
ChangeToDir (oldDirname);
105
// FREE MALLOC'ED GETCWD BUFFER.
111
}/* end extern C definitions */