1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-26 09:08:44 +02:00

Commit mildy modified version of a patch by Joseph Gay to handle and convert relative paths in LOF files (i.e. relative to path of LOF file)

This commit is contained in:
richardash1981 2010-03-06 22:42:53 +00:00
parent b0e23dbaf7
commit bd192bfa2b

View File

@ -138,6 +138,8 @@ private:
void doScrollOffset(); void doScrollOffset();
wxTextFile *mTextFile; wxTextFile *mTextFile;
wxFileName *mLOFFileName; /**< The name of the LOF file, which is used to
interpret relative paths in it */
AudacityProject *mProject; AudacityProject *mProject;
// In order to know whether or not to create a new window // In order to know whether or not to create a new window
@ -157,6 +159,7 @@ LOFImportFileHandle::LOFImportFileHandle(const wxString & name, wxTextFile *file
mTextFile(file) mTextFile(file)
{ {
mProject = GetActiveProject(); mProject = GetActiveProject();
mLOFFileName = new wxFileName(name);
windowCalledOnce = false; windowCalledOnce = false;
callDurationFactor = false; callDurationFactor = false;
durationFactor = 1; durationFactor = 1;
@ -359,6 +362,15 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln)
tokenholder = temptok1.GetNextToken(); tokenholder = temptok1.GetNextToken();
targetfile = temptok1.GetNextToken(); targetfile = temptok1.GetNextToken();
// If path is relative, make absolute path from LOF path
if(!wxIsAbsolutePath(targetfile)) {
wxFileName fName(targetfile);
fName.Normalize(wxPATH_NORM_ALL, mLOFFileName->GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
if(fName.FileExists()) {
targetfile = fName.GetFullPath();
}
}
#ifdef USE_MIDI #ifdef USE_MIDI
// If file is a midi // If file is a midi
if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false) if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false)
@ -492,6 +504,9 @@ LOFImportFileHandle::~LOFImportFileHandle()
mTextFile->Close(); mTextFile->Close();
delete mTextFile; delete mTextFile;
} }
if(mLOFFileName) {
delete mLOFFileName;
}
} }
// Indentation settings for Vim and Emacs and unique identifier for Arch, a // Indentation settings for Vim and Emacs and unique identifier for Arch, a