From bd192bfa2b7f0d674b51e8843ea7d4519abeae53 Mon Sep 17 00:00:00 2001 From: richardash1981 Date: Sat, 6 Mar 2010 22:42:53 +0000 Subject: [PATCH] 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) --- src/import/ImportLOF.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/import/ImportLOF.cpp b/src/import/ImportLOF.cpp index cb4714b35..e7713bb9e 100644 --- a/src/import/ImportLOF.cpp +++ b/src/import/ImportLOF.cpp @@ -138,6 +138,8 @@ private: void doScrollOffset(); wxTextFile *mTextFile; + wxFileName *mLOFFileName; /**< The name of the LOF file, which is used to + interpret relative paths in it */ AudacityProject *mProject; // 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) { mProject = GetActiveProject(); + mLOFFileName = new wxFileName(name); windowCalledOnce = false; callDurationFactor = false; durationFactor = 1; @@ -358,6 +361,15 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln) // To identify filename and open it tokenholder = 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 // If file is a midi @@ -492,6 +504,9 @@ LOFImportFileHandle::~LOFImportFileHandle() mTextFile->Close(); delete mTextFile; } + if(mLOFFileName) { + delete mLOFFileName; + } } // Indentation settings for Vim and Emacs and unique identifier for Arch, a