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)
38
START_NAMESPACE( Aqsis )
40
//---------------------------------------------------------------------
41
/** Given a string representing a filename with wildcards, return a list
42
* of filenames that match that string.
44
std::list<CqString*> CqFile::Glob ( const CqString& strFileGlob )
48
const char *pt = strFileGlob.c_str();
50
std::list<CqString*> result;
51
if ( ( hFile = _findfirst( pt, &c_file ) ) != -1L )
53
/* we found something here; then we list
54
* all of them with the directory first
56
CqString strFile( c_file.name );
57
result.push_front( &strFile );
58
while ( _findnext( hFile, &c_file ) == 0 )
60
result.push_front( new CqString( c_file.name ) );
70
//---------------------------------------------------------------------
71
/** Get the searchpath for a the specified asset type. The way in which the
72
* searchpath is specified is OS specific. Under Windows, environment variables
75
* \param strAsset The name of the asset whose searchpath is to be returned, i.e. "shaders".
76
* \return A string containing the ":" separated list of searchpaths.
79
CqString CqFile::GetSystemSetting( const CqString& strAsset )
82
char* base_path = ".";
83
CqString result( "" );
85
if ( ( env = getenv( "AQSIS_BASE_PATH" ) ) != NULL )
89
if ( strAsset.compare( "base" ) == 0 )
93
else if ( strAsset.compare( "config" ) == 0 )
95
if ( ( env = getenv( "AQSIS_CONFIG" ) ) != NULL )
100
result.append( "/.aqsisrc" );
103
std::ifstream cfgfile( result.c_str() );
104
if ( !cfgfile.is_open() )
105
if ( ( env = getenv( "HOME" ) ) != NULL )
108
result.append( "/.aqsisrc" );
109
std::ifstream cfgfile( result.c_str() );
110
if ( !cfgfile.is_open() )
116
else if ( strAsset.compare( "shaders" ) == 0 )
118
if ( ( env = getenv( "AQSIS_SHADERS_PATH" ) ) != 0 )
123
result.append( "/shaders" );
126
else if ( strAsset.compare( "archives" ) == 0 )
128
if ( ( env = getenv( "AQSIS_ARCHIVES_PATH" ) ) != 0 )
133
result.append( "/archives" );
136
else if ( strAsset.compare( "textures" ) == 0 )
138
if ( ( env = getenv( "AQSIS_TEXTURES_PATH" ) ) != 0 )
143
result.append( "/textures" );
146
else if ( strAsset.compare( "displays" ) == 0 )
148
if ( ( env = getenv( "AQSIS_DISPLAYS_PATH" ) ) != 0 )
153
result.append( "/displays" );
156
else if ( strAsset.compare( "dsolibs" ) == 0 )
158
if ( ( env = getenv( "AQSIS_DSO_LIBS" ) ) != 0 )
163
result.append( "/dso" );
171
CqString CqFile::FixupPath(CqString& strPath)
173
if( strPath.find("//",0,2) == 0 )
175
if(strPath[3] == '/')
177
CqString strNewPath(strPath.substr(2,1));
178
strNewPath.append(":/");
179
strNewPath.append(strPath.substr(4));
180
//std::cout << strNewPath.c_str() << std::endl;
189
END_NAMESPACE( Aqsis )
190
//---------------------------------------------------------------------