1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-13 22:21:11 +02:00

Sweep for filename copying: import and export

This commit is contained in:
Paul Licameli
2016-02-21 23:21:11 -05:00
parent 8f02213e23
commit c3cca71461
6 changed files with 19 additions and 17 deletions

View File

@@ -98,7 +98,7 @@ public:
~ExportFFmpeg() override; ~ExportFFmpeg() override;
/// Callback, called from GetFilename /// Callback, called from GetFilename
bool CheckFileName(wxFileName &filename, int format = 0); bool CheckFileName(wxFileName &filename, int format = 0) override;
/// Format intialization /// Format intialization
bool Init(const char *shortname, AudacityProject *project, const Tags *metadata, int subformat); bool Init(const char *shortname, AudacityProject *project, const Tags *metadata, int subformat);

View File

@@ -920,24 +920,28 @@ int ExportMultiple::ExportMultipleByTrack(bool byName,
} }
int ExportMultiple::DoExport(int channels, int ExportMultiple::DoExport(int channels,
wxFileName name, const wxFileName &inName,
bool selectedOnly, bool selectedOnly,
double t0, double t0,
double t1, double t1,
const Tags &tags) const Tags &tags)
{ {
wxLogDebug(wxT("Doing multiple Export: File name \"%s\""), (name.GetFullName()).c_str()); wxFileName name;
wxLogDebug(wxT("Doing multiple Export: File name \"%s\""), (inName.GetFullName()).c_str());
wxLogDebug(wxT("Channels: %i, Start: %lf, End: %lf "), channels, t0, t1); wxLogDebug(wxT("Channels: %i, Start: %lf, End: %lf "), channels, t0, t1);
if (selectedOnly) wxLogDebug(wxT("Selected Region Only")); if (selectedOnly) wxLogDebug(wxT("Selected Region Only"));
else wxLogDebug(wxT("Whole Project")); else wxLogDebug(wxT("Whole Project"));
if (mOverwrite->GetValue()) { if (mOverwrite->GetValue()) {
// Make sure we don't overwrite (corrupt) alias files // Make sure we don't overwrite (corrupt) alias files
if (!mProject->GetDirManager()->EnsureSafeFilename(name)) { if (!mProject->GetDirManager()->EnsureSafeFilename(inName)) {
return false; return false;
} }
name = inName;
} }
else { else {
name = inName;
int i = 2; int i = 2;
wxString base(name.GetName()); wxString base(name.GetName());
while (name.FileExists()) { while (name.FileExists()) {
@@ -946,9 +950,10 @@ int ExportMultiple::DoExport(int channels,
} }
// Call the format export routine // Call the format export routine
const wxString fullPath{name.GetFullPath()};
int success = mPlugins[mPluginIndex]->Export(mProject, int success = mPlugins[mPluginIndex]->Export(mProject,
channels, channels,
name.GetFullPath(), fullPath,
selectedOnly, selectedOnly,
t0, t0,
t1, t1,
@@ -957,7 +962,7 @@ int ExportMultiple::DoExport(int channels,
mSubFormatIndex); mSubFormatIndex);
if (success == eProgressSuccess || success == eProgressStopped) { if (success == eProgressSuccess || success == eProgressStopped) {
mExported.Add(name.GetFullPath()); mExported.Add(fullPath);
} }
Refresh(); Refresh();

View File

@@ -74,7 +74,7 @@ private:
* @param tags Metadata to include in the file (if possible). * @param tags Metadata to include in the file (if possible).
*/ */
int DoExport(int channels, int DoExport(int channels,
wxFileName name, const wxFileName &name,
bool selectedOnly, bool selectedOnly,
double t0, double t0,
double t1, double t1,

View File

@@ -145,7 +145,7 @@ private:
void doScrollOffset(); void doScrollOffset();
wxTextFile *mTextFile; wxTextFile *mTextFile;
wxFileName *mLOFFileName; /**< The name of the LOF file, which is used to wxFileName mLOFFileName; /**< The name of the LOF file, which is used to
interpret relative paths in it */ interpret relative paths in it */
AudacityProject *mProject; AudacityProject *mProject;
@@ -164,9 +164,9 @@ private:
LOFImportFileHandle::LOFImportFileHandle(const wxString & name, wxTextFile *file) LOFImportFileHandle::LOFImportFileHandle(const wxString & name, wxTextFile *file)
: ImportFileHandle(name), : ImportFileHandle(name),
mTextFile(file) mTextFile(file)
, mLOFFileName{name}
{ {
mProject = GetActiveProject(); mProject = GetActiveProject();
mLOFFileName = new wxFileName(name);
windowCalledOnce = false; windowCalledOnce = false;
callDurationFactor = false; callDurationFactor = false;
durationFactor = 1; durationFactor = 1;
@@ -374,7 +374,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln)
// If path is relative, make absolute path from LOF path // If path is relative, make absolute path from LOF path
if(!wxIsAbsolutePath(targetfile)) { if(!wxIsAbsolutePath(targetfile)) {
wxFileName fName(targetfile); wxFileName fName(targetfile);
fName.Normalize(wxPATH_NORM_ALL, mLOFFileName->GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)); fName.Normalize(wxPATH_NORM_ALL, mLOFFileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
if(fName.FileExists()) { if(fName.FileExists()) {
targetfile = fName.GetFullPath(); targetfile = fName.GetFullPath();
} }
@@ -507,7 +507,4 @@ LOFImportFileHandle::~LOFImportFileHandle()
mTextFile->Close(); mTextFile->Close();
delete mTextFile; delete mTextFile;
} }
if(mLOFFileName) {
delete mLOFFileName;
}
} }

View File

@@ -326,9 +326,9 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
&bitstream); &bitstream);
if (bytesRead == OV_HOLE) { if (bytesRead == OV_HOLE) {
wxFileName f(mFilename); wxFileName ff(mFilename);
wxLogError(wxT("Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"), wxLogError(wxT("Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"),
f.GetFullName().c_str()); ff.GetFullName().c_str());
/* http://lists.xiph.org/pipermail/vorbis-dev/2001-February/003223.html /* http://lists.xiph.org/pipermail/vorbis-dev/2001-February/003223.html
* is the justification for doing this - best effort for malformed file, * is the justification for doing this - best effort for malformed file,
* hence the message. * hence the message.

View File

@@ -135,11 +135,11 @@ public:
// identify the filename being imported. // identify the filename being imported.
void CreateProgress() void CreateProgress()
{ {
wxFileName f(mFilename); wxFileName ff(mFilename);
wxString title; wxString title;
title.Printf(_("Importing %s"), GetFileDescription().c_str()); title.Printf(_("Importing %s"), GetFileDescription().c_str());
mProgress.create(title, f.GetFullName()); mProgress.create(title, ff.GetFullName());
} }
// This is similar to GetImporterDescription, but if possible the // This is similar to GetImporterDescription, but if possible the