Fix write file bug when file is in the project path and no path is defined.

This commit is contained in:
Wayne Stambaugh 2011-11-11 11:08:58 -05:00
parent 4221c3619a
commit 77521c4b60
1 changed files with 17 additions and 9 deletions

View File

@ -542,27 +542,35 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
{
wxString msg;
wxFileName fn = aFileName;
wxCHECK_MSG( aFileName.IsOk(), false,
// Check for absence of a file path with a file name. Unfortunately KiCad
// uses paths relative to the current project path without the ./ part which
// confuses wxFileName. Making the file name path absolute may be less than
// elegant but it solves the problem.
if( fn.GetPath().IsEmpty() && fn.HasName() )
fn.MakeAbsolute();
wxCHECK_MSG( fn.IsOk(), false,
wxT( "File name object is invalid. Bad programmer!" ) );
wxCHECK_MSG( !aFileName.GetPath().IsEmpty(), false,
wxT( "File name object path <" ) + aFileName.GetFullPath() +
wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
wxT( "File name object path <" ) + fn.GetFullPath() +
wxT( "> is not set. Bad programmer!" ) );
if( aFileName.IsDir() && !aFileName.IsDirWritable() )
if( fn.IsDir() && !fn.IsDirWritable() )
{
msg.Printf( _( "You do not have write permissions to folder <%s>." ),
GetChars( aFileName.GetPath() ) );
GetChars( fn.GetPath() ) );
}
else if( !aFileName.FileExists() && !aFileName.IsDirWritable() )
else if( !fn.FileExists() && !fn.IsDirWritable() )
{
msg.Printf( _( "You do not have write permissions to save file <%s> to folder <%s>." ),
GetChars( aFileName.GetFullName() ), GetChars( aFileName.GetPath() ) );
GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
}
else if( aFileName.FileExists() && !aFileName.IsFileWritable() )
else if( fn.FileExists() && !fn.IsFileWritable() )
{
msg.Printf( _( "You do not have write permissions to save file <%s>." ),
GetChars( aFileName.GetFullPath() ) );
GetChars( fn.GetFullPath() ) );
}
if( !msg.IsEmpty() )