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
# define S_ISDIR(mode) (mode&S_IFDIR)
24
# define STRUCT_STAT struct _stat
26
# define GETCWD _getcwd
27
# define MKDIR(A) _mkdir(A)
28
# define STAT(A,S) _stat(A,S)
32
# include <malloc/malloc.h>
37
# include <sys/param.h>
39
# define MAX_PATH MAXPATHLEN
40
# define STRUCT_STAT struct stat
42
# define GETCWD getcwd
43
# define MKDIR(A) mkdir(A, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)// set mode of directory to drwxr-xr-x.
44
# define STAT(A,S) stat(A,S)
45
#endif //_LINUX _APPLE
47
//-----------------------------------------------------------------------
48
static char* GetCurrDir()
50
// GETCWD MALLOCS A BUFFER. REMEMBER TO FREE IT.
58
//-----------------------------------------------------------------------
59
bool DirExists(const char *Dirname)
63
if (STAT(Dirname, &st))
65
// doesn't exist; must create it
68
if (S_ISDIR(st.st_mode) == 0)
70
// it's not a dir, must create a dir
75
//-----------------------------------------------------------------------
76
char * ChangeToDir (const char *Dirname)
80
if (STAT(Dirname, &st))
82
// doen't exist; must create it
85
if (S_ISDIR(st.st_mode) == 0)
87
// it's not a dir, must create a dir
90
char *oldDirname = GetCurrDir ();
96
void RetablishDir(char *oldDirname)
98
if (oldDirname != NULL)
100
ChangeToDir (oldDirname);
101
// FREE MALLOC'ED GETCWD BUFFER.
107
}/* end extern C definitions */