mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-19 17:11:12 +02:00
more progress on bug 113
better handling of error conditions in all BuildFromXML methods, per comment: // BuildFromXML methods should always return a BlockFile, not NULL, // even if the result is flawed (e.g., refers to nonexistent file), // as testing will be done in DirManager::ProjectFSCK().
This commit is contained in:
@@ -173,6 +173,7 @@ class AUDACITY_DLL_API WaveTrack: public Track {
|
||||
///for use with On-Demand decoding of compressed files.
|
||||
///decodeType should be an enum from ODDecodeTask that specifies what
|
||||
///Type of encoded file this is, such as eODFLAC
|
||||
//vvv Why not use the ODTypeEnum typedef to enforce that for the parameter?
|
||||
bool AppendCoded(wxString fName, sampleCount start,
|
||||
sampleCount len, int channel, int decodeType);
|
||||
|
||||
|
@@ -78,11 +78,13 @@ void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
xmlFile.EndTag(wxT("legacyblockfile"));
|
||||
}
|
||||
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *LegacyAliasBlockFile::BuildFromXML(wxString projDir, const wxChar **attrs)
|
||||
{
|
||||
wxFileName summaryFileName;
|
||||
wxFileName aliasFileName;
|
||||
|
||||
int aliasStart=0, aliasLen=0, aliasChannel=0;
|
||||
int summaryLen=0;
|
||||
bool noRMS = false;
|
||||
@@ -92,17 +94,15 @@ BlockFile *LegacyAliasBlockFile::BuildFromXML(wxString projDir, const wxChar **a
|
||||
{
|
||||
const wxChar *attr = *attrs++;
|
||||
const wxChar *value = *attrs++;
|
||||
|
||||
if (!value)
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStricmp(attr, wxT("name")) )
|
||||
{
|
||||
if (!XMLValueChecker::IsGoodFileName(strValue, projDir))
|
||||
return NULL;
|
||||
if (!wxStricmp(attr, wxT("name")) && XMLValueChecker::IsGoodFileName(strValue, projDir))
|
||||
//vvv Should this be
|
||||
// dm.AssignFile(summaryFileName, strValue, false);
|
||||
// as in PCMAliasBlockFile::BuildFromXML? Test with an old project.
|
||||
summaryFileName.Assign(projDir, strValue, wxT(""));
|
||||
}
|
||||
else if ( !wxStricmp(attr, wxT("aliaspath")) )
|
||||
{
|
||||
if (XMLValueChecker::IsGoodPathName(strValue))
|
||||
@@ -110,32 +110,27 @@ BlockFile *LegacyAliasBlockFile::BuildFromXML(wxString projDir, const wxChar **a
|
||||
else if (XMLValueChecker::IsGoodFileName(strValue, projDir))
|
||||
// Allow fallback of looking for the file name, located in the data directory.
|
||||
aliasFileName.Assign(projDir, strValue);
|
||||
else
|
||||
return NULL;
|
||||
else if (XMLValueChecker::IsGoodPathString(strValue))
|
||||
// If the aliased file is missing, we failed XMLValueChecker::IsGoodPathName()
|
||||
// and XMLValueChecker::IsGoodFileName, because both do existence tests,
|
||||
// but we want to keep the reference to the missing file because it's a good path string.
|
||||
aliasFileName.Assign(strValue);
|
||||
}
|
||||
else if (XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
{ // integer parameters
|
||||
if( !wxStricmp(attr, wxT("aliasstart")) )
|
||||
{ // integer parameters
|
||||
if (!wxStricmp(attr, wxT("aliasstart")) && (nValue >= 0))
|
||||
aliasStart = nValue;
|
||||
if( !wxStricmp(attr, wxT("aliaslen")) )
|
||||
else if (!wxStricmp(attr, wxT("aliaslen")) && (nValue >= 0))
|
||||
aliasLen = nValue;
|
||||
if( !wxStricmp(attr, wxT("aliaschannel")) )
|
||||
else if (!wxStricmp(attr, wxT("aliaschannel")) && XMLValueChecker::IsValidChannel(aliasChannel))
|
||||
aliasChannel = nValue;
|
||||
if( !wxStricmp(attr, wxT("summarylen")) )
|
||||
else if (!wxStricmp(attr, wxT("summarylen")) && (nValue > 0))
|
||||
summaryLen = nValue;
|
||||
if( !wxStricmp(attr, wxT("norms")) )
|
||||
else if (!wxStricmp(attr, wxT("norms")))
|
||||
noRMS = (nValue != 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!XMLValueChecker::IsGoodFileName(summaryFileName.GetFullName(),
|
||||
summaryFileName.GetPath(wxPATH_GET_VOLUME)) ||
|
||||
!XMLValueChecker::IsGoodFileName(aliasFileName.GetFullName(),
|
||||
aliasFileName.GetPath(wxPATH_GET_VOLUME)) ||
|
||||
(aliasStart < 0) || (aliasLen <= 0) ||
|
||||
!XMLValueChecker::IsValidChannel(aliasChannel) || (summaryLen <= 0))
|
||||
return NULL;
|
||||
|
||||
return new LegacyAliasBlockFile(summaryFileName, aliasFileName,
|
||||
aliasStart, aliasLen, aliasChannel,
|
||||
summaryLen, noRMS);
|
||||
|
@@ -283,6 +283,9 @@ void LegacyBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
xmlFile.EndTag(wxT("legacyblockfile"));
|
||||
}
|
||||
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
/// static
|
||||
BlockFile *LegacyBlockFile::BuildFromXML(wxString projDir, const wxChar **attrs,
|
||||
sampleCount len, sampleFormat format)
|
||||
@@ -296,39 +299,28 @@ BlockFile *LegacyBlockFile::BuildFromXML(wxString projDir, const wxChar **attrs,
|
||||
{
|
||||
const wxChar *attr = *attrs++;
|
||||
const wxChar *value = *attrs++;
|
||||
|
||||
if (!value)
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStrcmp(attr, wxT("name")) )
|
||||
{
|
||||
if (!XMLValueChecker::IsGoodFileName(strValue, projDir))
|
||||
return NULL;
|
||||
if (!wxStricmp(attr, wxT("name")) && XMLValueChecker::IsGoodFileName(strValue, projDir))
|
||||
//vvv Should this be
|
||||
// dm.AssignFile(fileName, strValue, false);
|
||||
// as in PCMAliasBlockFile::BuildFromXML? Test with an old project.
|
||||
fileName.Assign(projDir, strValue);
|
||||
}
|
||||
else if (XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
{ // integer parameters
|
||||
if( !wxStrcmp(attr, wxT("len")) )
|
||||
{ // integer parameters
|
||||
if (!wxStrcmp(attr, wxT("len")) && (nValue >= 0))
|
||||
len = nValue;
|
||||
if( !wxStrcmp(attr, wxT("norms")) )
|
||||
else if (!wxStrcmp(attr, wxT("norms")))
|
||||
noRMS = (nValue != 0);
|
||||
if( !wxStrcmp(attr, wxT("format")) )
|
||||
{
|
||||
if (!XMLValueChecker::IsValidSampleFormat(nValue))
|
||||
return NULL;
|
||||
else if (!wxStrcmp(attr, wxT("format")) && XMLValueChecker::IsValidSampleFormat(nValue))
|
||||
format = (sampleFormat)nValue;
|
||||
}
|
||||
if( !wxStrcmp(attr, wxT("summarylen")) )
|
||||
else if (!wxStrcmp(attr, wxT("summarylen")) && (nValue > 0))
|
||||
summaryLen = nValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!XMLValueChecker::IsGoodFileName(fileName.GetFullName(),
|
||||
fileName.GetPath(wxPATH_GET_VOLUME)) ||
|
||||
(len <= 0) || (summaryLen <= 0))
|
||||
return NULL;
|
||||
|
||||
return new LegacyBlockFile(fileName, format, summaryLen, len, noRMS);
|
||||
}
|
||||
|
||||
|
@@ -216,18 +216,17 @@ void ODDecodeBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
|
||||
/// Constructs a ODPCMAliasBlockFile from the xml output of WriteXML.
|
||||
/// Also schedules the ODPCMAliasBlockFile for OD loading.
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
|
||||
wxFileName summaryFileName;
|
||||
wxFileName audioFileName;
|
||||
sampleCount aliasStart=0, aliasLen=0;
|
||||
int aliasChannel=0;
|
||||
long nValue;
|
||||
unsigned int decodeType=0;
|
||||
float rms=0.0f;
|
||||
|
||||
|
||||
|
||||
while(*attrs)
|
||||
{
|
||||
@@ -237,20 +236,14 @@ BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStricmp(attr, wxT("summaryfile")) )
|
||||
{
|
||||
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
if (!XMLValueChecker::IsGoodFileString(strValue))
|
||||
return NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (strValue.Length() + 1 + dm.GetProjectDataDir().Length() > MAX_PATH)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
dm.AssignFile(summaryFileName,value,FALSE);
|
||||
}
|
||||
if (!wxStricmp(attr, wxT("summaryfile")) &&
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
XMLValueChecker::IsGoodFileString(strValue)
|
||||
#ifdef _WIN32
|
||||
&& (strValue.Length() + 1 + dm.GetProjectDataDir().Length() <= MAX_PATH)
|
||||
#endif
|
||||
)
|
||||
dm.AssignFile(summaryFileName, strValue, false);
|
||||
else if( !wxStricmp(attr, wxT("audiofile")) )
|
||||
{
|
||||
if (XMLValueChecker::IsGoodPathName(strValue))
|
||||
@@ -258,28 +251,25 @@ BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
else if (XMLValueChecker::IsGoodFileName(strValue, dm.GetProjectDataDir()))
|
||||
// Allow fallback of looking for the file name, located in the data directory.
|
||||
audioFileName.Assign(dm.GetProjectDataDir(), strValue);
|
||||
else
|
||||
return NULL;
|
||||
else if (XMLValueChecker::IsGoodPathString(strValue))
|
||||
// If the file is missing, we failed XMLValueChecker::IsGoodPathName()
|
||||
// and XMLValueChecker::IsGoodFileName, because both do existence tests,
|
||||
// but we want to keep the reference to the file because it's a good path string.
|
||||
audioFileName.Assign(strValue);
|
||||
}
|
||||
else if (XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
{ // integer parameters
|
||||
if( !wxStricmp(attr, wxT("aliasstart")) )
|
||||
{ // integer parameters
|
||||
if (!wxStricmp(attr, wxT("aliasstart")) && (nValue >= 0))
|
||||
aliasStart = nValue;
|
||||
else if( !wxStricmp(attr, wxT("aliaslen")) )
|
||||
else if (!wxStricmp(attr, wxT("aliaslen")) && (nValue >= 0))
|
||||
aliasLen = nValue;
|
||||
else if( !wxStricmp(attr, wxT("aliaschannel")) )
|
||||
else if (!wxStricmp(attr, wxT("aliaschannel")) && XMLValueChecker::IsValidChannel(aliasChannel))
|
||||
aliasChannel = nValue;
|
||||
else if( !wxStricmp(attr, wxT("decodetype")) )
|
||||
decodeType = nValue;
|
||||
}
|
||||
}
|
||||
|
||||
//file doesn't exist, but IsGoodFileName Checks that it does - maybe we should have a different method to check for valid names?
|
||||
if ( /*!XMLValueChecker::IsGoodFileName(summaryFileName.GetFullName(), summaryFileName.GetPath(wxPATH_GET_VOLUME)) || */
|
||||
!XMLValueChecker::IsGoodFileName(audioFileName.GetFullName(), audioFileName.GetPath(wxPATH_GET_VOLUME)) ||
|
||||
(aliasLen <= 0) || (aliasLen < 0.0) || !XMLValueChecker::IsValidChannel(aliasChannel) || (rms < 0.0))
|
||||
return NULL;
|
||||
|
||||
return new ODDecodeBlockFile(summaryFileName, audioFileName,
|
||||
aliasStart, aliasLen, aliasChannel,decodeType);
|
||||
|
||||
|
@@ -284,13 +284,15 @@ void ODPCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
|
||||
/// Constructs a ODPCMAliasBlockFile from the xml output of WriteXML.
|
||||
/// Does not schedule the ODPCMAliasBlockFile for OD loading. Client code must do this.
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileName summaryFileName;
|
||||
wxFileName aliasFileName;
|
||||
sampleCount aliasStart=0, aliasLen=0;
|
||||
int aliasChannel=0;
|
||||
float rms=0;
|
||||
long nValue;
|
||||
|
||||
while(*attrs)
|
||||
@@ -301,20 +303,14 @@ BlockFile *ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attr
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStricmp(attr, wxT("summaryfile")) )
|
||||
{
|
||||
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
if (!XMLValueChecker::IsGoodFileString(strValue))
|
||||
return NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (strValue.Length() + 1 + dm.GetProjectDataDir().Length() > MAX_PATH)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
dm.AssignFile(summaryFileName,value,FALSE);
|
||||
}
|
||||
if (!wxStricmp(attr, wxT("summaryfile")) &&
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
XMLValueChecker::IsGoodFileString(strValue)
|
||||
#ifdef _WIN32
|
||||
&& (strValue.Length() + 1 + dm.GetProjectDataDir().Length() <= MAX_PATH)
|
||||
#endif
|
||||
)
|
||||
dm.AssignFile(summaryFileName, strValue, false);
|
||||
else if( !wxStricmp(attr, wxT("aliasfile")) )
|
||||
{
|
||||
if (XMLValueChecker::IsGoodPathName(strValue))
|
||||
@@ -322,28 +318,25 @@ BlockFile *ODPCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attr
|
||||
else if (XMLValueChecker::IsGoodFileName(strValue, dm.GetProjectDataDir()))
|
||||
// Allow fallback of looking for the file name, located in the data directory.
|
||||
aliasFileName.Assign(dm.GetProjectDataDir(), strValue);
|
||||
else
|
||||
return NULL;
|
||||
else if (XMLValueChecker::IsGoodPathString(strValue))
|
||||
// If the aliased file is missing, we failed XMLValueChecker::IsGoodPathName()
|
||||
// and XMLValueChecker::IsGoodFileName, because both do existence tests,
|
||||
// but we want to keep the reference to the missing file because it's a good path string.
|
||||
aliasFileName.Assign(strValue);
|
||||
}
|
||||
else if (XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
{ // integer parameters
|
||||
if( !wxStricmp(attr, wxT("aliasstart")) )
|
||||
{ // integer parameters
|
||||
if (!wxStricmp(attr, wxT("aliasstart")) && (nValue >= 0))
|
||||
aliasStart = nValue;
|
||||
else if( !wxStricmp(attr, wxT("aliaslen")) )
|
||||
else if (!wxStricmp(attr, wxT("aliaslen")) && (nValue >= 0))
|
||||
aliasLen = nValue;
|
||||
else if( !wxStricmp(attr, wxT("aliaschannel")) )
|
||||
else if (!wxStricmp(attr, wxT("aliaschannel")) && XMLValueChecker::IsValidChannel(aliasChannel))
|
||||
aliasChannel = nValue;
|
||||
}
|
||||
}
|
||||
|
||||
//file doesn't exist, but IsGoodFileName Checks that it does - maybe we should have a different method to check for valid names?
|
||||
if ( /*!XMLValueChecker::IsGoodFileName(summaryFileName.GetFullName(), summaryFileName.GetPath(wxPATH_GET_VOLUME)) || */
|
||||
!XMLValueChecker::IsGoodFileName(aliasFileName.GetFullName(), aliasFileName.GetPath(wxPATH_GET_VOLUME)) ||
|
||||
(aliasLen <= 0) || (aliasLen < 0.0) || !XMLValueChecker::IsValidChannel(aliasChannel) || (rms < 0.0))
|
||||
return NULL;
|
||||
|
||||
return new ODPCMAliasBlockFile(summaryFileName, aliasFileName,
|
||||
aliasStart, aliasLen, aliasChannel);
|
||||
aliasStart, aliasLen, aliasChannel);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -180,12 +180,15 @@ void PCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
xmlFile.EndTag(wxT("pcmaliasblockfile"));
|
||||
}
|
||||
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
BlockFile *PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileName summaryFileName;
|
||||
wxFileName aliasFileName;
|
||||
int aliasStart=0, aliasLen=0, aliasChannel=0;
|
||||
float min=0, max=0, rms=0;
|
||||
float min = 0.0f, max = 0.0f, rms = 0.0f;
|
||||
double dblValue;
|
||||
long nValue;
|
||||
|
||||
@@ -197,18 +200,15 @@ BlockFile *PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStricmp(attr, wxT("summaryfile")) )
|
||||
{
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
if (XMLValueChecker::IsGoodFileString(strValue))
|
||||
{
|
||||
if (!wxStricmp(attr, wxT("summaryfile")) &&
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
XMLValueChecker::IsGoodFileString(strValue)
|
||||
#ifdef _WIN32
|
||||
if (strValue.Length() + 1 + dm.GetProjectDataDir().Length() <= MAX_PATH)
|
||||
&& (strValue.Length() + 1 + dm.GetProjectDataDir().Length() <= MAX_PATH)
|
||||
#endif
|
||||
dm.AssignFile(summaryFileName, strValue, false);
|
||||
}
|
||||
}
|
||||
else if( !wxStricmp(attr, wxT("aliasfile")) )
|
||||
)
|
||||
dm.AssignFile(summaryFileName, strValue, false);
|
||||
else if (!wxStricmp(attr, wxT("aliasfile")))
|
||||
{
|
||||
if (XMLValueChecker::IsGoodPathName(strValue))
|
||||
aliasFileName.Assign(strValue);
|
||||
@@ -222,49 +222,36 @@ BlockFile *PCMAliasBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
aliasFileName.Assign(strValue);
|
||||
}
|
||||
else if (XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
{ // integer parameters
|
||||
if( !wxStricmp(attr, wxT("aliasstart")) )
|
||||
{
|
||||
if (nValue >= 0)
|
||||
aliasStart = nValue;
|
||||
}
|
||||
else if( !wxStricmp(attr, wxT("aliaslen")) )
|
||||
{
|
||||
if (nValue >= 0)
|
||||
aliasLen = nValue;
|
||||
}
|
||||
else if( !wxStricmp(attr, wxT("aliaschannel")) )
|
||||
{
|
||||
if (XMLValueChecker::IsValidChannel(aliasChannel))
|
||||
aliasChannel = nValue;
|
||||
}
|
||||
else if( !wxStricmp(attr, wxT("min")) )
|
||||
{ // integer parameters
|
||||
if (!wxStricmp(attr, wxT("aliasstart")) && (nValue >= 0))
|
||||
aliasStart = nValue;
|
||||
else if (!wxStricmp(attr, wxT("aliaslen")) && (nValue >= 0))
|
||||
aliasLen = nValue;
|
||||
else if (!wxStricmp(attr, wxT("aliaschannel")) && XMLValueChecker::IsValidChannel(aliasChannel))
|
||||
aliasChannel = nValue;
|
||||
else if (!wxStricmp(attr, wxT("min")))
|
||||
min = nValue;
|
||||
else if( !wxStricmp(attr, wxT("max")) )
|
||||
else if (!wxStricmp(attr, wxT("max")))
|
||||
max = nValue;
|
||||
else if( !wxStricmp(attr, wxT("rms")) )
|
||||
{
|
||||
if (nValue >= 0)
|
||||
rms = nValue;
|
||||
}
|
||||
else if (!wxStricmp(attr, wxT("rms")) && (nValue >= 0))
|
||||
rms = nValue;
|
||||
}
|
||||
//the min/max can be (are?) doubles as well, so handle this case:
|
||||
else if( !wxStrcmp(attr, wxT("min")) &&
|
||||
XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
min = dblValue;
|
||||
else if( !wxStrcmp(attr, wxT("max")) &&
|
||||
XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
max = dblValue;
|
||||
else if( !wxStrcmp(attr, wxT("rms")) &&
|
||||
XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
rms = dblValue;
|
||||
|
||||
// mchinen: the min/max can be (are?) doubles as well, so handle those cases.
|
||||
// Vaughan: The code to which I added the XMLValueChecker checks
|
||||
// used wxAtoi to convert the string to an int.
|
||||
// So it's possible some prior project formats used ints (?), so am keeping
|
||||
// those above, but yes, we need to handle floats.
|
||||
else if (XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
{ // double parameters
|
||||
if (!wxStricmp(attr, wxT("min")))
|
||||
min = dblValue;
|
||||
else if (!wxStricmp(attr, wxT("max")))
|
||||
max = dblValue;
|
||||
else if (!wxStricmp(attr, wxT("rms")) && (dblValue >= 0.0))
|
||||
rms = dblValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Even if, for example, we know aliasFileName is blank,
|
||||
// create a PCMAliasBlockFile, so it gets put on DirManager's
|
||||
// mBlockFileHash and gets discovered in DirManager::ProjectFSCK(),
|
||||
// where user will get to decide what to do about it.
|
||||
return new PCMAliasBlockFile(summaryFileName, aliasFileName,
|
||||
aliasStart, aliasLen, aliasChannel,
|
||||
min, max, rms);
|
||||
|
@@ -46,6 +46,9 @@ void SilentBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
xmlFile.EndTag(wxT("silentblockfile"));
|
||||
}
|
||||
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
/// static
|
||||
BlockFile *SilentBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
@@ -56,19 +59,17 @@ BlockFile *SilentBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
const wxChar *attr = *attrs++;
|
||||
const wxChar *value = *attrs++;
|
||||
|
||||
if (!value)
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStrcmp(attr, wxT("len")) &&
|
||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
len = nValue;
|
||||
if (!wxStrcmp(attr, wxT("len")) &&
|
||||
XMLValueChecker::IsGoodInt(strValue) &&
|
||||
strValue.ToLong(&nValue) &&
|
||||
len > 0)
|
||||
len = nValue;
|
||||
}
|
||||
|
||||
if (len <= 0)
|
||||
return NULL;
|
||||
|
||||
return new SilentBlockFile(len);
|
||||
}
|
||||
|
||||
|
@@ -468,11 +468,14 @@ void SimpleBlockFile::SaveXML(XMLWriter &xmlFile)
|
||||
xmlFile.EndTag(wxT("simpleblockfile"));
|
||||
}
|
||||
|
||||
// BuildFromXML methods should always return a BlockFile, not NULL,
|
||||
// even if the result is flawed (e.g., refers to nonexistent file),
|
||||
// as testing will be done in DirManager::ProjectFSCK().
|
||||
/// static
|
||||
BlockFile *SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
wxFileName fileName;
|
||||
float min=0, max=0, rms=0;
|
||||
float min = 0.0f, max = 0.0f, rms = 0.0f;
|
||||
sampleCount len = 0;
|
||||
double dblValue;
|
||||
long nValue;
|
||||
@@ -481,41 +484,33 @@ BlockFile *SimpleBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
|
||||
{
|
||||
const wxChar *attr = *attrs++;
|
||||
const wxChar *value = *attrs++;
|
||||
|
||||
if (!value)
|
||||
break;
|
||||
|
||||
const wxString strValue = value;
|
||||
if( !wxStrcmp(attr, wxT("filename")) )
|
||||
{
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
if (!XMLValueChecker::IsGoodFileString(strValue))
|
||||
return NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (strValue.Length() + 1 + dm.GetProjectDataDir().Length() > MAX_PATH)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (!wxStricmp(attr, wxT("filename")) &&
|
||||
// Can't use XMLValueChecker::IsGoodFileName here, but do part of its test.
|
||||
XMLValueChecker::IsGoodFileString(strValue)
|
||||
#ifdef _WIN32
|
||||
&& (strValue.Length() + 1 + dm.GetProjectDataDir().Length() <= MAX_PATH)
|
||||
#endif
|
||||
)
|
||||
dm.AssignFile(fileName,value,FALSE);
|
||||
}
|
||||
else if( !wxStrcmp(attr, wxT("len")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
|
||||
else if (!wxStrcmp(attr, wxT("len")) &&
|
||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue) &&
|
||||
len > 0)
|
||||
len = nValue;
|
||||
else if( !wxStrcmp(attr, wxT("min")) &&
|
||||
XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
min = dblValue;
|
||||
else if( !wxStrcmp(attr, wxT("max")) &&
|
||||
XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
max = dblValue;
|
||||
else if( !wxStrcmp(attr, wxT("rms")) &&
|
||||
XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
rms = dblValue;
|
||||
else if (XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue))
|
||||
{ // double parameters
|
||||
if (!wxStricmp(attr, wxT("min")))
|
||||
min = dblValue;
|
||||
else if (!wxStricmp(attr, wxT("max")))
|
||||
max = dblValue;
|
||||
else if (!wxStricmp(attr, wxT("rms")) && (dblValue >= 0.0))
|
||||
rms = dblValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!XMLValueChecker::IsGoodFileString(fileName.GetFullName()) ||
|
||||
(len <= 0) || (rms < 0.0))
|
||||
return NULL;
|
||||
|
||||
return new SimpleBlockFile(fileName, len, min, max, rms);
|
||||
}
|
||||
|
||||
|
@@ -40,9 +40,6 @@ class ODFileDecoder;
|
||||
class ODDecodeTask:public ODTask
|
||||
{
|
||||
public:
|
||||
// Constructor / Destructor
|
||||
|
||||
/// Constructs an ODTask
|
||||
ODDecodeTask();
|
||||
virtual ~ODDecodeTask(){};
|
||||
|
||||
|
Reference in New Issue
Block a user