1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 07:59:27 +02:00

Bug 328 (P2) - do not allow writing to paths that are also missing alias files.

This commit is contained in:
mchinen 2011-04-02 23:56:02 +00:00
parent 3a7d00394f
commit 26c84929a6
3 changed files with 47 additions and 17 deletions

View File

@ -38,23 +38,6 @@
#include "ShuttleGui.h"
#include "Track.h"
class AliasedFile
{
public:
AliasedFile(wxFileName fileName, wxLongLong byteCount, bool bOriginalExists)
{
mFileName = fileName;
mByteCount = byteCount;
mbOriginalExists = bOriginalExists;
};
wxFileName mFileName;
wxLongLong mByteCount; // if stored as current default sample format
bool mbOriginalExists;
};
WX_DECLARE_OBJARRAY(AliasedFile, AliasedFileArray);
// Note, this #include must occur here, not up with the others!
// It must be between the WX_DECLARE_OBJARRAY and WX_DEFINE_OBJARRAY.
#include <wx/arrimpl.cpp>

View File

@ -14,8 +14,27 @@
#ifndef __AUDACITY_DEPENDENCIES__
#define __AUDACITY_DEPENDENCIES__
#include <wx/dynarray.h>
class AudacityProject;
class AliasedFile
{
public:
AliasedFile(wxFileName fileName, wxLongLong byteCount, bool bOriginalExists)
{
mFileName = fileName;
mByteCount = byteCount;
mbOriginalExists = bOriginalExists;
};
wxFileName mFileName;
wxLongLong mByteCount; // if stored as current default sample format
bool mbOriginalExists;
};
WX_DECLARE_OBJARRAY(AliasedFile, AliasedFileArray);
// Checks for alias block files, modifies the project if the
// user requests it, and returns True if the user continues.
// Returns false if the user clicks Cancel, meaning that they do
@ -23,4 +42,8 @@ class AudacityProject;
bool ShowDependencyDialogIfNeeded(AudacityProject *project,
bool isSaving);
// Returns a list of aliased files associated with a project.
void FindDependencies(AudacityProject *project,
AliasedFileArray *outAliasedFiles);
#endif

View File

@ -73,6 +73,7 @@
#include "../widgets/Warning.h"
#include "../AColor.h"
#include "../TimeTrack.h"
#include "../Dependencies.h"
// Callback to display format options
static void ExportCallback(void *cbdata, int index)
@ -635,6 +636,29 @@ bool Exporter::GetFilename()
continue;
}
// Check to see if we are writing to a path that a missing aliased file existed at.
// This causes problems for the exporter, so we don't allow it.
// Overwritting non-missing aliased files is okay.
// Also, this can only happen for uncompressed audio.
size_t i;
bool overwritingMissingAlias;
overwritingMissingAlias = false;
for (size_t i = 0; i < gAudacityProjects.GetCount(); i++) {
AliasedFileArray aliasedFiles;
FindDependencies(gAudacityProjects[i], &aliasedFiles);
if (mFilename.GetFullPath() == aliasedFiles[i].mFileName.GetFullPath() &&
!mFilename.FileExists()) {
// Warn and return to the dialog
wxMessageBox(_("You are attempting to overwrite an aliased file that is missing.\n\
The file cannot be written because the path is needed to restore the original audio to the project.\n\
You can see the missing files in File > Check Dependencies.\n\
If you still wish to export, please choose a different filename."));
overwritingMissingAlias = true;
}
}
if (overwritingMissingAlias)
continue;
if (mFilename.FileExists()) {
wxString prompt;