Bugfix: create 3d config path if nonexistent
This commit is contained in:
parent
a2fe783f53
commit
4924db7491
|
@ -424,42 +424,51 @@ bool S3D_CACHE::Set3DConfigDir( const wxString& aConfigDir )
|
|||
if( !m_ConfigDir.empty() )
|
||||
return false;
|
||||
|
||||
wxFileName cfgdir( aConfigDir, "" );
|
||||
wxFileName cfgdir( aConfigDir, wxT( "" ) );
|
||||
cfgdir.Normalize();
|
||||
|
||||
if( cfgdir.DirExists() )
|
||||
if( !cfgdir.DirExists() )
|
||||
{
|
||||
m_ConfigDir = cfgdir.GetPath();
|
||||
|
||||
// inform the file resolver of the config directory
|
||||
if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) )
|
||||
{
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * could not set 3D Config Directory on filename resolver\n";
|
||||
std::cerr << " * config directory: '" << m_ConfigDir.ToUTF8() << "'\n";
|
||||
}
|
||||
|
||||
cfgdir.AppendDir( wxT( "cache" ) );
|
||||
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
|
||||
|
||||
if( !cfgdir.DirExists() )
|
||||
{
|
||||
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
|
||||
|
||||
if( !cfgdir.DirExists() )
|
||||
{
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * failed to create 3D cache directory\n";
|
||||
std::cerr << " * cache directory: '";
|
||||
std::cerr << cfgdir.GetPath().ToUTF8() << "'\n";
|
||||
return false;
|
||||
}
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * failed to create 3D configuration directory\n";
|
||||
std::cerr << " * config directory: '";
|
||||
std::cerr << cfgdir.GetPath().ToUTF8() << "'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_CacheDir = cfgdir.GetPathWithSep();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
m_ConfigDir = cfgdir.GetPath();
|
||||
|
||||
// inform the file resolver of the config directory
|
||||
if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) )
|
||||
{
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * could not set 3D Config Directory on filename resolver\n";
|
||||
std::cerr << " * config directory: '" << m_ConfigDir.ToUTF8() << "'\n";
|
||||
}
|
||||
|
||||
cfgdir.AppendDir( wxT( "cache" ) );
|
||||
|
||||
if( !cfgdir.DirExists() )
|
||||
{
|
||||
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
|
||||
|
||||
if( !cfgdir.DirExists() )
|
||||
{
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * failed to create 3D cache directory\n";
|
||||
std::cerr << " * cache directory: '";
|
||||
std::cerr << cfgdir.GetPath().ToUTF8() << "'\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_CacheDir = cfgdir.GetPathWithSep();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ bool S3D_FILENAME_RESOLVER::Set3DConfigDir( const wxString& aConfigDir )
|
|||
if( aConfigDir.empty() )
|
||||
return false;
|
||||
|
||||
wxFileName cfgdir( aConfigDir, "" );
|
||||
wxFileName cfgdir( aConfigDir, wxT( "" ) );
|
||||
cfgdir.Normalize();
|
||||
|
||||
if( false == cfgdir.DirExists() )
|
||||
|
@ -56,7 +56,7 @@ bool S3D_FILENAME_RESOLVER::SetProjectDir( const wxString& aProjDir, bool* flgCh
|
|||
if( aProjDir.empty() )
|
||||
return false;
|
||||
|
||||
wxFileName projdir( aProjDir, "" );
|
||||
wxFileName projdir( aProjDir, wxT( "" ) );
|
||||
projdir.Normalize();
|
||||
|
||||
if( false == projdir.DirExists() )
|
||||
|
@ -248,7 +248,7 @@ bool S3D_FILENAME_RESOLVER::addPath( const wxString& aPath )
|
|||
if( aPath.empty() )
|
||||
return false;
|
||||
|
||||
wxFileName path( aPath, "" );
|
||||
wxFileName path( aPath, wxT( "" ) );
|
||||
path.Normalize();
|
||||
|
||||
if( !path.DirExists() )
|
||||
|
@ -382,7 +382,8 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
|||
if( m_Paths.empty() || 1 == m_Paths.size() )
|
||||
return false;
|
||||
|
||||
wxString cfgname = m_ConfigDir + S3D_RESOLVER_CONFIG;
|
||||
wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG );
|
||||
wxString cfgname = cfgpath.GetFullPath();
|
||||
std::ofstream cfgFile;
|
||||
|
||||
cfgFile.open( cfgname.ToUTF8(), std::ios_base::trunc );
|
||||
|
@ -403,7 +404,7 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
|||
|
||||
while( sPL != ePL )
|
||||
{
|
||||
cfgFile << "\"" << (*sPL).ToUTF8() << "\"\n";
|
||||
cfgFile << "\"" << sPL->ToUTF8() << "\"\n";
|
||||
++sPL;
|
||||
}
|
||||
|
||||
|
@ -429,7 +430,7 @@ wxString S3D_FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName )
|
|||
|
||||
while( sL != eL )
|
||||
{
|
||||
wxFileName fpath( *sL, "" );
|
||||
wxFileName fpath( *sL, wxT( "" ) );
|
||||
wxString fps = fpath.GetPathWithSep();
|
||||
|
||||
if( std::string::npos != fname.find( fps ) )
|
||||
|
|
Loading…
Reference in New Issue