Blender  V2.93
GHOST_ISystemPaths.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
28 #include <stdio.h> /* just for NULL */
29 
30 #include "GHOST_ISystemPaths.h"
31 
32 #ifdef WIN32
33 # include "GHOST_SystemPathsWin32.h"
34 #else
35 # ifdef __APPLE__
36 # include "GHOST_SystemPathsCocoa.h"
37 # else
38 # include "GHOST_SystemPathsUnix.h"
39 # endif
40 #endif
41 
42 GHOST_ISystemPaths *GHOST_ISystemPaths::m_systemPaths = NULL;
43 
45 {
46  GHOST_TSuccess success;
47  if (!m_systemPaths) {
48 #ifdef WIN32
49  m_systemPaths = new GHOST_SystemPathsWin32();
50 #else
51 # ifdef __APPLE__
52  m_systemPaths = new GHOST_SystemPathsCocoa();
53 # else
54  m_systemPaths = new GHOST_SystemPathsUnix();
55 # endif
56 #endif
57  success = m_systemPaths != NULL ? GHOST_kSuccess : GHOST_kFailure;
58  }
59  else {
60  success = GHOST_kFailure;
61  }
62  return success;
63 }
64 
66 {
68  if (m_systemPaths) {
69  delete m_systemPaths;
70  m_systemPaths = NULL;
71  }
72  else {
73  success = GHOST_kFailure;
74  }
75  return success;
76 }
77 
79 {
80  if (!m_systemPaths) {
81  create();
82  }
83  return m_systemPaths;
84 }
GHOST_TSuccess
Definition: GHOST_Types.h:91
@ GHOST_kFailure
Definition: GHOST_Types.h:91
@ GHOST_kSuccess
Definition: GHOST_Types.h:91
static GHOST_TSuccess create()
static GHOST_TSuccess dispose()
static GHOST_ISystemPaths * get()