2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Implements the system specific parts of the CqFile class for handling files.
23
\author Paul C. Gregory (pgregory@aqsis.com)
37
START_NAMESPACE( Aqsis )
39
//---------------------------------------------------------------------
40
/** Given a string representing a filename with wildcards, return a list
41
* of filenames that match that string.
43
std::list<CqString*> CqFile::Glob ( const CqString& strFileGlob )
46
const char *pt = strFileGlob.c_str();
49
glob( pt, GLOB_DOOFFS, NULL, &globbuf );
51
std::list<CqString*> result;
53
for ( i = 0;i < globbuf.gl_pathc;i++ )
55
result.push_front( new CqString( globbuf.gl_pathv[ i ] ) );
64
//---------------------------------------------------------------------
65
/** Get the searchpath for a the specified asset type. The way in which the
66
* searchpath is specified is OS specific. Under Windows, environment variables
69
* \param strAsset The name of the asset whose searchpath is to be returned, i.e. "shaders".
70
* \return A string containing the ":" separated list of searchpaths.
73
CqString CqFile::GetSystemSetting( const CqString& strAsset )
77
CqString result( "" );
79
if ( ( env = getenv( "AQSIS_BASE_PATH" ) ) != NULL )
85
// use the default from the build system
86
base_path = BASE_PATH;
90
if ( strAsset.compare( "base" ) == 0 )
94
else if ( strAsset.compare( "config" ) == 0 )
96
if ( ( env = getenv( "AQSIS_CONFIG" ) ) != NULL )
100
result = CONFIG_PATH;
101
result.append( "/aqsisrc" );
104
std::ifstream cfgfile( result.c_str() );
105
if ( !cfgfile.is_open() )
106
if ( ( env = getenv( "HOME" ) ) != NULL )
109
result.append( "/.aqsisrc" );
110
std::ifstream cfgfile( result.c_str() );
111
if ( !cfgfile.is_open() )
117
else if ( strAsset.compare( "shaders" ) == 0 )
119
if ( ( env = getenv( "AQSIS_SHADERS_PATH" ) ) != 0 )
123
result = CqString( ".:" ) + base_path;
124
result.append( "/shaders" );
127
else if ( strAsset.compare( "archives" ) == 0 )
129
if ( ( env = getenv( "AQSIS_ARCHIVES_PATH" ) ) != 0 )
133
result = CqString( ".:" ) + base_path;
134
result.append( "/archives" );
137
else if ( strAsset.compare( "textures" ) == 0 )
139
if ( ( env = getenv( "AQSIS_TEXTURES_PATH" ) ) != 0 )
143
result = CqString( ".:" ) + base_path;
144
result.append( "/textures" );
147
else if ( strAsset.compare( "displays" ) == 0 )
149
if ( ( env = getenv( "AQSIS_DISPLAYS_PATH" ) ) != 0 )
154
result.append( "/displays" );
157
else if ( strAsset.compare( "procedurals" ) == 0 )
159
if ( ( env = getenv( "AQSIS_PROCEDURALS" ) ) != 0 )
163
result = CqString( ".:" ) + base_path;
164
result.append( "/procedurals" );
167
else if ( strAsset.compare( "dsolibs" ) == 0 )
169
if ( ( env = getenv( "AQSIS_DSO_LIBS" ) ) != 0 )
174
result.append( "/dso" );
181
CqString CqFile::FixupPath(CqString& strPath)
187
END_NAMESPACE( Aqsis )
188
//---------------------------------------------------------------------