mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-09 17:07:43 +02:00
Sweep for filename copying: various
This commit is contained in:
parent
2d7e21536e
commit
f00144e9a5
@ -832,7 +832,7 @@ void AudacityApp::OnMRUClear(wxCommandEvent& WXUNUSED(event))
|
|||||||
// Better, for example, to check the file type early on.
|
// Better, for example, to check the file type early on.
|
||||||
void AudacityApp::OnMRUFile(wxCommandEvent& event) {
|
void AudacityApp::OnMRUFile(wxCommandEvent& event) {
|
||||||
int n = event.GetId() - ID_RECENT_FIRST;
|
int n = event.GetId() - ID_RECENT_FIRST;
|
||||||
wxString fullPathStr = mRecentFiles->GetHistoryFile(n);
|
const wxString &fullPathStr = mRecentFiles->GetHistoryFile(n);
|
||||||
|
|
||||||
// Try to open only if not already open.
|
// Try to open only if not already open.
|
||||||
// Test IsAlreadyOpen() here even though AudacityProject::MRUOpen() also now checks,
|
// Test IsAlreadyOpen() here even though AudacityProject::MRUOpen() also now checks,
|
||||||
@ -852,7 +852,8 @@ void AudacityApp::OnTimer(wxTimerEvent& WXUNUSED(event))
|
|||||||
if (ofqueue.GetCount()) {
|
if (ofqueue.GetCount()) {
|
||||||
// Load each file on the queue
|
// Load each file on the queue
|
||||||
while (ofqueue.GetCount()) {
|
while (ofqueue.GetCount()) {
|
||||||
wxString name(ofqueue[0]);
|
wxString name;
|
||||||
|
name.swap(ofqueue[0]);
|
||||||
ofqueue.RemoveAt(0);
|
ofqueue.RemoveAt(0);
|
||||||
|
|
||||||
// Get the user's attention if no file name was specified
|
// Get the user's attention if no file name was specified
|
||||||
@ -1860,14 +1861,14 @@ void AudacityApp::AddUniquePathToPathList(const wxString &pathArg,
|
|||||||
{
|
{
|
||||||
wxFileName pathNorm = pathArg;
|
wxFileName pathNorm = pathArg;
|
||||||
pathNorm.Normalize();
|
pathNorm.Normalize();
|
||||||
wxString path = pathNorm.GetFullPath();
|
const wxString newpath{ pathNorm.GetFullPath() };
|
||||||
|
|
||||||
for(unsigned int i=0; i<pathList.GetCount(); i++) {
|
for(unsigned int i=0; i<pathList.GetCount(); i++) {
|
||||||
if (wxFileName(path) == wxFileName(pathList[i]))
|
if (wxFileName(newpath) == wxFileName(pathList[i]))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pathList.Add(path);
|
pathList.Add(newpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -1894,11 +1895,11 @@ void AudacityApp::FindFilesInPathList(const wxString & pattern,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileName f;
|
wxFileName ff;
|
||||||
|
|
||||||
for(size_t i = 0; i < pathList.GetCount(); i++) {
|
for(size_t i = 0; i < pathList.GetCount(); i++) {
|
||||||
f = pathList[i] + wxFILE_SEP_PATH + pattern;
|
ff = pathList[i] + wxFILE_SEP_PATH + pattern;
|
||||||
wxDir::GetAllFiles(f.GetPath(), &results, f.GetFullName(), flags);
|
wxDir::GetAllFiles(ff.GetPath(), &results, ff.GetFullName(), flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void AutoRecoveryDialog::PopulateList()
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (bool c = dir.GetFirst(&filename, wxT("*.autosave"), wxDIR_FILES);
|
for (bool c = dir.GetFirst(&filename, wxT("*.autosave"), wxDIR_FILES);
|
||||||
c; c = dir.GetNext(&filename))
|
c; c = dir.GetNext(&filename))
|
||||||
mFileList->InsertItem(i++, wxFileName(filename).GetName());
|
mFileList->InsertItem(i++, wxFileName{ filename }.GetName());
|
||||||
|
|
||||||
mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
|
mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
|
||||||
}
|
}
|
||||||
@ -685,10 +685,11 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
|||||||
char ident[sizeof(AutoSaveIdent)];
|
char ident[sizeof(AutoSaveIdent)];
|
||||||
size_t len = strlen(AutoSaveIdent);
|
size_t len = strlen(AutoSaveIdent);
|
||||||
|
|
||||||
wxFileName fn(fileName);
|
const wxFileName fn(fileName);
|
||||||
|
const wxString fnPath{fn.GetFullPath()};
|
||||||
wxFFile file;
|
wxFFile file;
|
||||||
|
|
||||||
if (!file.Open(fn.GetFullPath(), wxT("rb")))
|
if (!file.Open(fnPath, wxT("rb")))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -703,7 +704,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
|||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
// Add </project> tag, if necessary
|
// Add </project> tag, if necessary
|
||||||
if (!file.Open(fn.GetFullPath(), wxT("r+b")))
|
if (!file.Open(fnPath, wxT("r+b")))
|
||||||
{
|
{
|
||||||
// Really shouldn't happen, but let the caller deal with it
|
// Really shouldn't happen, but let the caller deal with it
|
||||||
return false;
|
return false;
|
||||||
@ -749,7 +750,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
|||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
// Decode to a temporary file to preserve the orignal.
|
// Decode to a temporary file to preserve the orignal.
|
||||||
wxString tempName = fn.CreateTempFileName(fn.GetFullPath());
|
wxString tempName = fn.CreateTempFileName(fnPath);
|
||||||
bool opened = false;
|
bool opened = false;
|
||||||
|
|
||||||
XMLFileWriter out;
|
XMLFileWriter out;
|
||||||
|
@ -413,7 +413,7 @@ bool BatchCommands::IsMono()
|
|||||||
|
|
||||||
wxString BatchCommands::BuildCleanFileName(const wxString &fileName, const wxString &extension)
|
wxString BatchCommands::BuildCleanFileName(const wxString &fileName, const wxString &extension)
|
||||||
{
|
{
|
||||||
wxFileName newFileName(fileName);
|
const wxFileName newFileName{ fileName };
|
||||||
wxString justName = newFileName.GetName();
|
wxString justName = newFileName.GetName();
|
||||||
wxString pathName = newFileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
|
wxString pathName = newFileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
|
||||||
|
|
||||||
@ -776,9 +776,10 @@ wxArrayString BatchCommands::GetNames()
|
|||||||
wxDir::GetAllFiles(FileNames::ChainDir(), &files, wxT("*.txt"), wxDIR_FILES);
|
wxDir::GetAllFiles(FileNames::ChainDir(), &files, wxT("*.txt"), wxDIR_FILES);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
wxFileName ff;
|
||||||
for (i = 0; i < files.GetCount(); i++) {
|
for (i = 0; i < files.GetCount(); i++) {
|
||||||
wxFileName f(files[i]);
|
ff = (files[i]);
|
||||||
names.Add(f.GetName());
|
names.Add(ff.GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
|
@ -262,12 +262,12 @@ int ufile_fopen_input(std::unique_ptr<FFmpegContext> &context_ptr, wxString & na
|
|||||||
context_ptr.reset();
|
context_ptr.reset();
|
||||||
auto context = std::make_unique<FFmpegContext>();
|
auto context = std::make_unique<FFmpegContext>();
|
||||||
|
|
||||||
wxFileName f(name);
|
wxFileName ff{ name };
|
||||||
wxCharBuffer fname;
|
wxCharBuffer fname;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
fname = f.GetFullName().mb_str();
|
fname = ff.GetFullName().mb_str();
|
||||||
filename = (const char *) fname;
|
filename = (const char *) fname;
|
||||||
|
|
||||||
// Open the file to prepare for probing
|
// Open the file to prepare for probing
|
||||||
@ -458,7 +458,7 @@ class FindFFmpegDialog final : public wxDialog
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FindFFmpegDialog(wxWindow *parent, wxString path, wxString name, wxString type)
|
FindFFmpegDialog(wxWindow *parent, const wxString &path, const wxString &name, const wxString &type)
|
||||||
: wxDialog(parent, wxID_ANY, wxString(_("Locate FFmpeg")))
|
: wxDialog(parent, wxID_ANY, wxString(_("Locate FFmpeg")))
|
||||||
{
|
{
|
||||||
SetName(GetTitle());
|
SetName(GetTitle());
|
||||||
@ -606,7 +606,7 @@ bool FFmpegLibs::FindLibs(wxWindow *parent)
|
|||||||
wxLogMessage(wxT("Looking for FFmpeg libraries..."));
|
wxLogMessage(wxT("Looking for FFmpeg libraries..."));
|
||||||
if (!mLibAVFormatPath.IsEmpty()) {
|
if (!mLibAVFormatPath.IsEmpty()) {
|
||||||
wxLogMessage(wxT("mLibAVFormatPath ('%s') is not empty."), mLibAVFormatPath.c_str());
|
wxLogMessage(wxT("mLibAVFormatPath ('%s') is not empty."), mLibAVFormatPath.c_str());
|
||||||
wxFileName fn = mLibAVFormatPath;
|
const wxFileName fn{ mLibAVFormatPath };
|
||||||
path = fn.GetPath();
|
path = fn.GetPath();
|
||||||
name = fn.GetFullName();
|
name = fn.GetFullName();
|
||||||
}
|
}
|
||||||
@ -663,7 +663,7 @@ bool FFmpegLibs::LoadLibs(wxWindow * WXUNUSED(parent), bool showerr)
|
|||||||
|
|
||||||
// If not successful, try loading it from default path
|
// If not successful, try loading it from default path
|
||||||
if (!mLibsLoaded && !GetLibAVFormatPath().IsEmpty()) {
|
if (!mLibsLoaded && !GetLibAVFormatPath().IsEmpty()) {
|
||||||
wxFileName fn(GetLibAVFormatPath(), GetLibAVFormatName());
|
const wxFileName fn{ GetLibAVFormatPath(), GetLibAVFormatName() };
|
||||||
wxString path = fn.GetFullPath();
|
wxString path = fn.GetFullPath();
|
||||||
wxLogMessage(wxT("Trying to load FFmpeg libraries from default path, '%s'."), path.c_str());
|
wxLogMessage(wxT("Trying to load FFmpeg libraries from default path, '%s'."), path.c_str());
|
||||||
mLibsLoaded = InitLibs(path,showerr);
|
mLibsLoaded = InitLibs(path,showerr);
|
||||||
@ -675,7 +675,7 @@ bool FFmpegLibs::LoadLibs(wxWindow * WXUNUSED(parent), bool showerr)
|
|||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
// If not successful, try loading it from legacy path
|
// If not successful, try loading it from legacy path
|
||||||
if (!mLibsLoaded && !GetLibAVFormatPath().IsEmpty()) {
|
if (!mLibsLoaded && !GetLibAVFormatPath().IsEmpty()) {
|
||||||
wxFileName fn(wxT("/usr/local/lib/audacity"), GetLibAVFormatName());
|
const wxFileName fn{wxT("/usr/local/lib/audacity"), GetLibAVFormatName()};
|
||||||
wxString path = fn.GetFullPath();
|
wxString path = fn.GetFullPath();
|
||||||
wxLogMessage(wxT("Trying to load FFmpeg libraries from legacy path, '%s'."), path.c_str());
|
wxLogMessage(wxT("Trying to load FFmpeg libraries from legacy path, '%s'."), path.c_str());
|
||||||
mLibsLoaded = InitLibs(path,showerr);
|
mLibsLoaded = InitLibs(path,showerr);
|
||||||
@ -738,9 +738,9 @@ bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr)
|
|||||||
if (wxGetEnv(wxT("PATH"),&syspath))
|
if (wxGetEnv(wxT("PATH"),&syspath))
|
||||||
{
|
{
|
||||||
wxLogMessage(wxT("PATH = '%s'"), syspath.c_str());
|
wxLogMessage(wxT("PATH = '%s'"), syspath.c_str());
|
||||||
wxString fmtdirsc = wxPathOnly(libpath_format) + wxT(";");
|
const wxString &fmtdir{ wxPathOnly(libpath_format) };
|
||||||
wxString scfmtdir = wxT(";") + wxPathOnly(libpath_format);
|
wxString fmtdirsc = fmtdir + wxT(";");
|
||||||
wxString fmtdir = wxPathOnly(libpath_format);
|
wxString scfmtdir = wxT(";") + fmtdir;
|
||||||
wxLogMessage(wxT("Checking that '%s' is in PATH..."), fmtdir.c_str());
|
wxLogMessage(wxT("Checking that '%s' is in PATH..."), fmtdir.c_str());
|
||||||
// If the directory, where libavformat is, is not in PATH - add it
|
// If the directory, where libavformat is, is not in PATH - add it
|
||||||
if (!syspath.Contains(fmtdirsc) && !syspath.Contains(scfmtdir) && !syspath.Contains(fmtdir))
|
if (!syspath.Contains(fmtdirsc) && !syspath.Contains(scfmtdir) && !syspath.Contains(fmtdir))
|
||||||
@ -780,20 +780,21 @@ bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr)
|
|||||||
wxDynamicLibrary *util = NULL;
|
wxDynamicLibrary *util = NULL;
|
||||||
wxFileName avcodec_filename;
|
wxFileName avcodec_filename;
|
||||||
wxFileName avutil_filename;
|
wxFileName avutil_filename;
|
||||||
wxFileName name(libpath_format);
|
wxFileName name{ libpath_format };
|
||||||
|
wxString nameFull{name.GetFullPath()};
|
||||||
bool gotError = false;
|
bool gotError = false;
|
||||||
|
|
||||||
// Check for a monolithic avformat
|
// Check for a monolithic avformat
|
||||||
avformat = new wxDynamicLibrary();
|
avformat = new wxDynamicLibrary();
|
||||||
wxLogMessage(wxT("Checking for monolithic avformat from '%s'."), name.GetFullPath().c_str());
|
wxLogMessage(wxT("Checking for monolithic avformat from '%s'."), nameFull.c_str());
|
||||||
gotError = !avformat->Load(name.GetFullPath(), wxDL_LAZY);
|
gotError = !avformat->Load(nameFull, wxDL_LAZY);
|
||||||
|
|
||||||
// Verify it really is monolithic
|
// Verify it really is monolithic
|
||||||
if (!gotError) {
|
if (!gotError) {
|
||||||
avutil_filename = FileNames::PathFromAddr(avformat->GetSymbol(wxT("avutil_version")));
|
avutil_filename = FileNames::PathFromAddr(avformat->GetSymbol(wxT("avutil_version")));
|
||||||
avcodec_filename = FileNames::PathFromAddr(avformat->GetSymbol(wxT("avcodec_version")));
|
avcodec_filename = FileNames::PathFromAddr(avformat->GetSymbol(wxT("avcodec_version")));
|
||||||
if (avutil_filename.GetFullPath().IsSameAs(name.GetFullPath())) {
|
if (avutil_filename.GetFullPath().IsSameAs(nameFull)) {
|
||||||
if (avcodec_filename.GetFullPath().IsSameAs(name.GetFullPath())) {
|
if (avcodec_filename.GetFullPath().IsSameAs(nameFull)) {
|
||||||
util = avformat;
|
util = avformat;
|
||||||
codec = avformat;
|
codec = avformat;
|
||||||
}
|
}
|
||||||
@ -816,22 +817,27 @@ bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The two wxFileNames don't change after this
|
||||||
|
const wxString avcodec_filename_full{ avcodec_filename.GetFullPath() };
|
||||||
|
const wxString avutil_filename_full{ avutil_filename.GetFullPath() };
|
||||||
|
|
||||||
if (!util) {
|
if (!util) {
|
||||||
avutil = util = new wxDynamicLibrary();
|
avutil = util = new wxDynamicLibrary();
|
||||||
wxLogMessage(wxT("Loading avutil from '%s'."), avutil_filename.GetFullPath().c_str());
|
wxLogMessage(wxT("Loading avutil from '%s'."), avutil_filename_full.c_str());
|
||||||
util->Load(avutil_filename.GetFullPath(), wxDL_LAZY);
|
util->Load(avutil_filename_full, wxDL_LAZY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!codec) {
|
if (!codec) {
|
||||||
avcodec = codec = new wxDynamicLibrary();
|
avcodec = codec = new wxDynamicLibrary();
|
||||||
wxLogMessage(wxT("Loading avcodec from '%s'."), avcodec_filename.GetFullPath().c_str());
|
wxLogMessage(wxT("Loading avcodec from '%s'."), avcodec_filename_full.c_str());
|
||||||
codec->Load(avcodec_filename.GetFullPath(), wxDL_LAZY);
|
codec->Load(avcodec_filename_full, wxDL_LAZY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!avformat->IsLoaded()) {
|
if (!avformat->IsLoaded()) {
|
||||||
name.SetFullName(libpath_format);
|
name.SetFullName(libpath_format);
|
||||||
wxLogMessage(wxT("Loading avformat from '%s'."), name.GetFullPath().c_str());
|
nameFull = name.GetFullPath();
|
||||||
gotError = !avformat->Load(name.GetFullPath(), wxDL_LAZY);
|
wxLogMessage(wxT("Loading avformat from '%s'."), nameFull.c_str());
|
||||||
|
gotError = !avformat->Load(nameFull, wxDL_LAZY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
|
@ -50,8 +50,7 @@ void Internat::Init()
|
|||||||
// wxLogDebug(wxT("Decimal separator set to '%c'"), mDecimalSeparator);
|
// wxLogDebug(wxT("Decimal separator set to '%c'"), mDecimalSeparator);
|
||||||
|
|
||||||
// Setup list of characters that aren't allowed in file names
|
// Setup list of characters that aren't allowed in file names
|
||||||
wxFileName tmpFile;
|
forbid = wxFileName::GetForbiddenChars();
|
||||||
forbid = tmpFile.GetForbiddenChars();
|
|
||||||
for(unsigned int i=0; i < forbid.Length(); i++)
|
for(unsigned int i=0; i < forbid.Length(); i++)
|
||||||
exclude.Add( forbid.Mid(i, 1) );
|
exclude.Add( forbid.Mid(i, 1) );
|
||||||
}
|
}
|
||||||
@ -183,15 +182,17 @@ char *Internat::VerifyFilename(const wxString &s, bool input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxFileName f(name);
|
wxFileName ff(name);
|
||||||
|
wxString ext;
|
||||||
while ((char *) (const char *)name.mb_str() == NULL) {
|
while ((char *) (const char *)name.mb_str() == NULL) {
|
||||||
wxMessageBox(_("The specified filename could not be converted due to Unicode character use."));
|
wxMessageBox(_("The specified filename could not be converted due to Unicode character use."));
|
||||||
|
|
||||||
|
ext = ff.GetExt();
|
||||||
name = FileSelector(_("Specify New Filename:"),
|
name = FileSelector(_("Specify New Filename:"),
|
||||||
wxEmptyString,
|
wxEmptyString,
|
||||||
name,
|
name,
|
||||||
f.GetExt(),
|
ext,
|
||||||
wxT("*.") + f.GetExt(),
|
wxT("*.") + ext,
|
||||||
wxFD_SAVE | wxRESIZE_BORDER,
|
wxFD_SAVE | wxRESIZE_BORDER,
|
||||||
wxGetTopLevelParent(NULL));
|
wxGetTopLevelParent(NULL));
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ static bool ConvertLegacyTrack(wxTextFile *f, XMLFileWriter &xmlFile)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConvertLegacyProjectFile(wxFileName filename)
|
bool ConvertLegacyProjectFile(const wxFileName &filename)
|
||||||
{
|
{
|
||||||
wxTextFile f;
|
wxTextFile f;
|
||||||
XMLFileWriter xmlFile;
|
XMLFileWriter xmlFile;
|
||||||
|
@ -11,4 +11,4 @@
|
|||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
|
||||||
bool ConvertLegacyProjectFile(wxFileName filename);
|
bool ConvertLegacyProjectFile(const wxFileName &filename);
|
||||||
|
@ -31,7 +31,7 @@ wxString PlatformCompatibility::GetLongFileName(const wxString& shortFileName)
|
|||||||
return fn.GetLongPath();
|
return fn.GetLongPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString PlatformCompatibility::GetExecutablePath()
|
const wxString &PlatformCompatibility::GetExecutablePath()
|
||||||
{
|
{
|
||||||
static bool found = false;
|
static bool found = false;
|
||||||
static wxString path;
|
static wxString path;
|
||||||
|
@ -36,8 +36,9 @@ public:
|
|||||||
//
|
//
|
||||||
// Get filename and path of executable (e.g. "/usr/bin/audacity" on
|
// Get filename and path of executable (e.g. "/usr/bin/audacity" on
|
||||||
// Linux or "C:\Program Files\Audacity\Audacity.exe" on Windows)
|
// Linux or "C:\Program Files\Audacity\Audacity.exe" on Windows)
|
||||||
|
// This string is unchanging
|
||||||
//
|
//
|
||||||
static wxString GetExecutablePath();
|
static const wxString &GetExecutablePath();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Audacity treats the / as a file seperator always for Mac OS,
|
// Audacity treats the / as a file seperator always for Mac OS,
|
||||||
|
@ -620,7 +620,7 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString path = plug.GetPath();
|
const wxString &path = plug.GetPath();
|
||||||
ItemData & item = mItems[path]; // will create NEW entry
|
ItemData & item = mItems[path]; // will create NEW entry
|
||||||
item.plugs.Add(&plug);
|
item.plugs.Add(&plug);
|
||||||
item.path = path;
|
item.path = path;
|
||||||
@ -1437,28 +1437,29 @@ void PluginManager::FindFilesInPathList(const wxString & pattern,
|
|||||||
|
|
||||||
// TODO: We REALLY need to figure out the "Audacity" plug-in path(s)
|
// TODO: We REALLY need to figure out the "Audacity" plug-in path(s)
|
||||||
|
|
||||||
wxFileName f;
|
|
||||||
wxArrayString paths;
|
wxArrayString paths;
|
||||||
|
|
||||||
// Add the "per-user" plug-ins directory
|
// Add the "per-user" plug-ins directory
|
||||||
f = FileNames::PlugInDir();
|
{
|
||||||
paths.Add(f.GetFullPath());
|
const wxFileName &ff = FileNames::PlugInDir();
|
||||||
|
paths.Add(ff.GetFullPath());
|
||||||
|
}
|
||||||
|
|
||||||
// Add the "Audacity" plug-ins directory
|
// Add the "Audacity" plug-ins directory
|
||||||
f = PlatformCompatibility::GetExecutablePath();
|
wxFileName ff = PlatformCompatibility::GetExecutablePath();
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
f.RemoveLastDir();
|
f.RemoveLastDir();
|
||||||
f.RemoveLastDir();
|
f.RemoveLastDir();
|
||||||
f.RemoveLastDir();
|
f.RemoveLastDir();
|
||||||
#endif
|
#endif
|
||||||
f.AppendDir(wxT("plug-ins"));
|
ff.AppendDir(wxT("plug-ins"));
|
||||||
paths.Add(f.GetPath());
|
paths.Add(ff.GetPath());
|
||||||
|
|
||||||
// Weed out duplicates
|
// Weed out duplicates
|
||||||
for (size_t i = 0, cnt = pathList.size(); i < cnt; i++)
|
for (size_t i = 0, cnt = pathList.size(); i < cnt; i++)
|
||||||
{
|
{
|
||||||
f = pathList[i];
|
ff = pathList[i];
|
||||||
wxString path = f.GetFullPath();
|
const wxString path{ ff.GetFullPath() };
|
||||||
if (paths.Index(path, wxFileName::IsCaseSensitive()) == wxNOT_FOUND)
|
if (paths.Index(path, wxFileName::IsCaseSensitive()) == wxNOT_FOUND)
|
||||||
{
|
{
|
||||||
paths.Add(path);
|
paths.Add(path);
|
||||||
@ -1468,8 +1469,8 @@ void PluginManager::FindFilesInPathList(const wxString & pattern,
|
|||||||
// Find all matching files in each path
|
// Find all matching files in each path
|
||||||
for (size_t i = 0, cnt = paths.GetCount(); i < cnt; i++)
|
for (size_t i = 0, cnt = paths.GetCount(); i < cnt; i++)
|
||||||
{
|
{
|
||||||
f = paths[i] + wxFILE_SEP_PATH + pattern;
|
ff = paths[i] + wxFILE_SEP_PATH + pattern;
|
||||||
wxDir::GetAllFiles(f.GetPath(), &files, f.GetFullName(), directories ? wxDIR_DEFAULT : wxDIR_FILES);
|
wxDir::GetAllFiles(ff.GetPath(), &files, ff.GetFullName(), directories ? wxDIR_DEFAULT : wxDIR_FILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -2796,10 +2797,10 @@ wxString PluginManager::SharedGroup(const PluginID & ID, const wxString & group)
|
|||||||
{
|
{
|
||||||
wxString path = SettingsPath(ID, true);
|
wxString path = SettingsPath(ID, true);
|
||||||
|
|
||||||
wxFileName f(group);
|
wxFileName ff(group);
|
||||||
if (!f.GetName().IsEmpty())
|
if (!ff.GetName().IsEmpty())
|
||||||
{
|
{
|
||||||
path += f.GetFullPath(wxPATH_UNIX) + wxCONFIG_PATH_SEPARATOR;
|
path += ff.GetFullPath(wxPATH_UNIX) + wxCONFIG_PATH_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
@ -2820,10 +2821,10 @@ wxString PluginManager::PrivateGroup(const PluginID & ID, const wxString & group
|
|||||||
{
|
{
|
||||||
wxString path = SettingsPath(ID, false);
|
wxString path = SettingsPath(ID, false);
|
||||||
|
|
||||||
wxFileName f(group);
|
wxFileName ff(group);
|
||||||
if (!f.GetName().IsEmpty())
|
if (!ff.GetName().IsEmpty())
|
||||||
{
|
{
|
||||||
path += f.GetFullPath(wxPATH_UNIX) + wxCONFIG_PATH_SEPARATOR;
|
path += ff.GetFullPath(wxPATH_UNIX) + wxCONFIG_PATH_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
@ -144,12 +144,14 @@ void InitPreferences()
|
|||||||
wxString langCode = gPrefs->Read(wxT("/Locale/Language"), wxEmptyString);
|
wxString langCode = gPrefs->Read(wxT("/Locale/Language"), wxEmptyString);
|
||||||
bool writeLang = false;
|
bool writeLang = false;
|
||||||
|
|
||||||
wxFileName fn(wxStandardPaths::Get().GetResourcesDir(), wxT("FirstTime.ini"));
|
const wxFileName fn(wxStandardPaths::Get().GetResourcesDir(), wxT("FirstTime.ini"));
|
||||||
if (fn.FileExists()) // it will exist if the (win) installer put it there
|
if (fn.FileExists()) // it will exist if the (win) installer put it there
|
||||||
{
|
{
|
||||||
|
const wxString fullPath{fn.GetFullPath()};
|
||||||
|
|
||||||
wxFileConfig ini(wxEmptyString,
|
wxFileConfig ini(wxEmptyString,
|
||||||
wxEmptyString,
|
wxEmptyString,
|
||||||
fn.GetFullPath(),
|
fullPath,
|
||||||
wxEmptyString,
|
wxEmptyString,
|
||||||
wxCONFIG_USE_LOCAL_FILE);
|
wxCONFIG_USE_LOCAL_FILE);
|
||||||
|
|
||||||
@ -167,11 +169,10 @@ void InitPreferences()
|
|||||||
|
|
||||||
ini.Read(wxT("/FromInno/ResetPrefs"), &resetPrefs, false);
|
ini.Read(wxT("/FromInno/ResetPrefs"), &resetPrefs, false);
|
||||||
|
|
||||||
bool gone = wxRemoveFile(fn.GetFullPath()); // remove FirstTime.ini
|
bool gone = wxRemoveFile(fullPath); // remove FirstTime.ini
|
||||||
if (!gone)
|
if (!gone)
|
||||||
{
|
{
|
||||||
wxString fileName = fn.GetFullPath();
|
wxMessageBox(wxString::Format(_("Failed to remove %s"), fullPath.c_str()), _("Failed!"));
|
||||||
wxMessageBox(wxString::Format( _("Failed to remove %s"), fileName.c_str()), _("Failed!"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2349,7 +2349,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
|
|||||||
|
|
||||||
void AudacityProject::OnOpenAudioFile(wxCommandEvent & event)
|
void AudacityProject::OnOpenAudioFile(wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
wxString cmd = event.GetString();
|
const wxString &cmd = event.GetString();
|
||||||
|
|
||||||
if (!cmd.IsEmpty()) {
|
if (!cmd.IsEmpty()) {
|
||||||
OpenFile(cmd);
|
OpenFile(cmd);
|
||||||
@ -2466,7 +2466,7 @@ wxArrayString AudacityProject::ShowOpenDialog(const wxString &extraformat, const
|
|||||||
// static method, can be called outside of a project
|
// static method, can be called outside of a project
|
||||||
bool AudacityProject::IsAlreadyOpen(const wxString & projPathName)
|
bool AudacityProject::IsAlreadyOpen(const wxString & projPathName)
|
||||||
{
|
{
|
||||||
wxFileName newProjPathName(projPathName);
|
const wxFileName newProjPathName(projPathName);
|
||||||
size_t numProjects = gAudacityProjects.Count();
|
size_t numProjects = gAudacityProjects.Count();
|
||||||
for (size_t i = 0; i < numProjects; i++)
|
for (size_t i = 0; i < numProjects; i++)
|
||||||
{
|
{
|
||||||
@ -2504,7 +2504,7 @@ void AudacityProject::OpenFiles(AudacityProject *proj)
|
|||||||
ODManager::Pause();
|
ODManager::Pause();
|
||||||
|
|
||||||
for (size_t ff = 0; ff < selectedFiles.GetCount(); ff++) {
|
for (size_t ff = 0; ff < selectedFiles.GetCount(); ff++) {
|
||||||
wxString fileName = selectedFiles[ff];
|
const wxString &fileName = selectedFiles[ff];
|
||||||
|
|
||||||
// Make sure it isn't already open.
|
// Make sure it isn't already open.
|
||||||
if (AudacityProject::IsAlreadyOpen(fileName))
|
if (AudacityProject::IsAlreadyOpen(fileName))
|
||||||
@ -2569,13 +2569,11 @@ bool AudacityProject::WarnOfLegacyFile( )
|
|||||||
// See comment in AudacityApp::MRUOpen().
|
// See comment in AudacityApp::MRUOpen().
|
||||||
void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
|
void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
|
||||||
{
|
{
|
||||||
wxString fileName(fileNameArg);
|
|
||||||
|
|
||||||
// On Win32, we may be given a short (DOS-compatible) file name on rare
|
// On Win32, we may be given a short (DOS-compatible) file name on rare
|
||||||
// occassions (e.g. stuff like "C:\PROGRA~1\AUDACI~1\PROJEC~1.AUP"). We
|
// occassions (e.g. stuff like "C:\PROGRA~1\AUDACI~1\PROJEC~1.AUP"). We
|
||||||
// convert these to long file name first.
|
// convert these to long file name first.
|
||||||
fileName = PlatformCompatibility::ConvertSlashInFileName(
|
wxString fileName = PlatformCompatibility::ConvertSlashInFileName(
|
||||||
PlatformCompatibility::GetLongFileName(fileName));
|
PlatformCompatibility::GetLongFileName(fileNameArg));
|
||||||
|
|
||||||
// Make sure it isn't already open.
|
// Make sure it isn't already open.
|
||||||
// Vaughan, 2011-03-25: This was done previously in AudacityProject::OpenFiles()
|
// Vaughan, 2011-03-25: This was done previously in AudacityProject::OpenFiles()
|
||||||
@ -2639,7 +2637,7 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
|
|||||||
if( !WarnOfLegacyFile() )
|
if( !WarnOfLegacyFile() )
|
||||||
return;
|
return;
|
||||||
// Convert to the NEW format.
|
// Convert to the NEW format.
|
||||||
bool success = ConvertLegacyProjectFile(wxFileName(fileName));
|
bool success = ConvertLegacyProjectFile(wxFileName{ fileName });
|
||||||
if (!success) {
|
if (!success) {
|
||||||
wxMessageBox(_("Audacity was unable to convert an Audacity 1.0 project to the new project format."),
|
wxMessageBox(_("Audacity was unable to convert an Audacity 1.0 project to the new project format."),
|
||||||
_("Error Opening Project"),
|
_("Error Opening Project"),
|
||||||
|
@ -619,7 +619,7 @@ void ThemeBase::CreateImageCache( bool bBinarySave )
|
|||||||
// IF nBinarySave, THEN saving to a normal PNG file.
|
// IF nBinarySave, THEN saving to a normal PNG file.
|
||||||
if( bBinarySave )
|
if( bBinarySave )
|
||||||
{
|
{
|
||||||
wxString FileName = FileNames::ThemeCachePng();
|
const wxString &FileName = FileNames::ThemeCachePng();
|
||||||
|
|
||||||
// Perhaps we should prompt the user if they are overwriting
|
// Perhaps we should prompt the user if they are overwriting
|
||||||
// an existing theme cache?
|
// an existing theme cache?
|
||||||
@ -650,7 +650,7 @@ void ThemeBase::CreateImageCache( bool bBinarySave )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SourceOutputStream OutStream;
|
SourceOutputStream OutStream;
|
||||||
wxString FileName = FileNames::ThemeCacheAsCee( );
|
const wxString &FileName = FileNames::ThemeCacheAsCee( );
|
||||||
if( !OutStream.OpenFile( FileName ))
|
if( !OutStream.OpenFile( FileName ))
|
||||||
{
|
{
|
||||||
wxMessageBox(
|
wxMessageBox(
|
||||||
@ -791,7 +791,7 @@ bool ThemeBase::ReadImageCache( bool bBinaryRead, bool bOkIfNotFound)
|
|||||||
// IF bBinary read THEN a normal read from a PNG file
|
// IF bBinary read THEN a normal read from a PNG file
|
||||||
if( bBinaryRead )
|
if( bBinaryRead )
|
||||||
{
|
{
|
||||||
wxString FileName = FileNames::ThemeCachePng();
|
const wxString &FileName = FileNames::ThemeCachePng();
|
||||||
if( !wxFileExists( FileName ))
|
if( !wxFileExists( FileName ))
|
||||||
{
|
{
|
||||||
if( bOkIfNotFound )
|
if( bOkIfNotFound )
|
||||||
|
@ -81,7 +81,7 @@ void FileHistory::Clear()
|
|||||||
AddFilesToMenu();
|
AddFilesToMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString FileHistory::GetHistoryFile(size_t i) const
|
const wxString &FileHistory::GetHistoryFile(size_t i) const
|
||||||
{
|
{
|
||||||
wxASSERT(i < mHistory.GetCount());
|
wxASSERT(i < mHistory.GetCount());
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class AUDACITY_DLL_API FileHistory
|
|||||||
void AddFilesToMenu(wxMenu *menu);
|
void AddFilesToMenu(wxMenu *menu);
|
||||||
|
|
||||||
size_t GetCount();
|
size_t GetCount();
|
||||||
wxString GetHistoryFile(size_t i) const;
|
const wxString &GetHistoryFile(size_t i) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t mMaxFiles;
|
size_t mMaxFiles;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user