Changed: Minor changes
This commit is contained in:
parent
493dc9982a
commit
ba8b11bfd8
17 changed files with 56 additions and 55 deletions
|
@ -825,14 +825,14 @@ bool CPersistentDataRecord::writeToFile(const std::string &fileName, TFileFormat
|
||||||
goto binary_file;
|
goto binary_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOMB("Bad file type supplied to writeToFile() - file not saved: "<<fileName,return false);
|
BOMB("Bad file type supplied to writeToFile() - file not saved: " << fileName, return false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// set of accessors for retrieving a data record from various sources
|
// set of accessors for retrieving a data record from various sources
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
bool CPersistentDataRecord::fromBuffer(const char *src,uint32 bufferSize)
|
bool CPersistentDataRecord::fromBuffer(const char *src, uint32 bufferSize)
|
||||||
{
|
{
|
||||||
H_AUTO(CPersistentDataRecordFromBuffer);
|
H_AUTO(CPersistentDataRecordFromBuffer);
|
||||||
|
|
||||||
|
@ -1133,7 +1133,7 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName)
|
||||||
// read the data
|
// read the data
|
||||||
uint32 blocksRead= (uint32)fread(&buffer[0],length,1,inf);
|
uint32 blocksRead= (uint32)fread(&buffer[0],length,1,inf);
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
DROP_IF( blocksRead!=1, "Failed to read data from file "<<fileName, return false);
|
DROP_IF( blocksRead!=1, "Failed to read data from file " << fileName, return false);
|
||||||
|
|
||||||
// test whether our data buffer is binary
|
// test whether our data buffer is binary
|
||||||
bool isBinary=(length>8 && *(uint32*)&buffer[4]==length);
|
bool isBinary=(length>8 && *(uint32*)&buffer[4]==length);
|
||||||
|
@ -1143,7 +1143,7 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// it's not a valid binary file so see whether it looks like a valid text file
|
// it's not a valid binary file so see whether it looks like a valid text file
|
||||||
DROP_IF(!buffer.isValidText(),"File is binary but 'file size' header entry doesn't match true file size",return false);
|
DROP_IF(!buffer.isValidText(),"File is binary but 'file size' header entry doesn't match true file size", return false);
|
||||||
|
|
||||||
// parse the data as text...
|
// parse the data as text...
|
||||||
return fromString(buffer);
|
return fromString(buffer);
|
||||||
|
@ -1153,13 +1153,13 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName)
|
||||||
// open the file
|
// open the file
|
||||||
CIFile f;
|
CIFile f;
|
||||||
bool open = f.open(fileName);
|
bool open = f.open(fileName);
|
||||||
DROP_IF( !open, "Failed to open input file "<<fileName, return false);
|
DROP_IF( !open, "Failed to open input file " << fileName, return false);
|
||||||
|
|
||||||
// get the file size
|
// get the file size
|
||||||
uint32 len= f.getFileSize();
|
uint32 len= f.getFileSize();
|
||||||
|
|
||||||
bool result= fromStream(f, len);
|
bool result= fromStream(f, len);
|
||||||
DROP_IF( !result, "Failed to parse input file "<<fileName, return false);
|
DROP_IF( !result, "Failed to parse input file " << fileName, return false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -1194,7 +1194,7 @@ bool CPersistentDataRecord::readFromBinFile(const std::string &fileName)
|
||||||
|
|
||||||
// parse the buffer contents to re-generate the data
|
// parse the buffer contents to re-generate the data
|
||||||
bool result= fromBuffer(&s[0],(uint32)s.size());
|
bool result= fromBuffer(&s[0],(uint32)s.size());
|
||||||
DROP_IF( !result, "Failed to parse input file "<<fileName, return false);
|
DROP_IF( !result, "Failed to parse input file " << fileName, return false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,7 +427,7 @@ public:
|
||||||
|
|
||||||
// read from a binary data buffer
|
// read from a binary data buffer
|
||||||
// if the input data looks like text then calls fromString()
|
// if the input data looks like text then calls fromString()
|
||||||
bool fromBuffer(const char *src,uint32 bufferSize);
|
bool fromBuffer(const char *src, uint32 bufferSize);
|
||||||
|
|
||||||
// read from a text string (either xml or lines)
|
// read from a text string (either xml or lines)
|
||||||
// note 1: This routine is not at all optimised
|
// note 1: This routine is not at all optimised
|
||||||
|
|
|
@ -268,13 +268,14 @@ NLMISC_CATEGORISED_COMMAND(utils,pdrInfo,"Extract info from pdr file(s)","<input
|
||||||
pdr.clear();
|
pdr.clear();
|
||||||
|
|
||||||
const CFileDescription& fd=fdc[j];
|
const CFileDescription& fd=fdc[j];
|
||||||
log.display("- %s: ",fd.FileName.quoteIfNotQuoted().c_str());
|
log.display("- %s: ", fd.FileName.quoteIfNotQuoted().c_str());
|
||||||
|
|
||||||
{
|
{
|
||||||
H_AUTO(pdrInfo_readFromFile)
|
H_AUTO(pdrInfo_readFromFile)
|
||||||
pdr.readFromFile(fd.FileName);
|
pdr.readFromFile(fd.FileName);
|
||||||
}
|
}
|
||||||
log.displayNL("%s",pdr.getInfo().c_str());
|
|
||||||
|
log.displayNL("%s", pdr.getInfo().c_str());
|
||||||
|
|
||||||
if (!outputFileName.empty())
|
if (!outputFileName.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,7 @@ void GenerateLZMA(const std::string sourceFile, const std::string &outputFile)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// old syntax incompatible with new versions
|
// old syntax incompatible with new versions
|
||||||
std::string cmd = "lzma e ";
|
std::string cmd = "lzma e";
|
||||||
cmd += " " + sourceFile + " " + outputFile;
|
cmd += " " + sourceFile + " " + outputFile;
|
||||||
nlinfo("Executing system command: %s", cmd.c_str());
|
nlinfo("Executing system command: %s", cmd.c_str());
|
||||||
}
|
}
|
||||||
|
@ -194,31 +194,31 @@ void CPackageDescription::setup(const std::string& packageName)
|
||||||
|
|
||||||
// root directory
|
// root directory
|
||||||
if (_RootDirectory.empty())
|
if (_RootDirectory.empty())
|
||||||
_RootDirectory= NLMISC::CFile::getPath(packageName);
|
_RootDirectory = NLMISC::CFile::getPath(packageName);
|
||||||
_RootDirectory= NLMISC::CPath::standardizePath(_RootDirectory,true);
|
_RootDirectory = NLMISC::CPath::standardizePath(_RootDirectory, true);
|
||||||
|
|
||||||
// patch directory
|
// patch directory
|
||||||
if (_PatchDirectory.empty())
|
if (_PatchDirectory.empty())
|
||||||
_PatchDirectory= _RootDirectory+"patch";
|
_PatchDirectory = _RootDirectory + "patch";
|
||||||
_PatchDirectory= NLMISC::CPath::standardizePath(_PatchDirectory,true);
|
_PatchDirectory = NLMISC::CPath::standardizePath(_PatchDirectory, true);
|
||||||
|
|
||||||
// BNP directory
|
// BNP directory
|
||||||
if (_BnpDirectory.empty())
|
if (_BnpDirectory.empty())
|
||||||
_BnpDirectory= _RootDirectory+"bnp";
|
_BnpDirectory = _RootDirectory+"bnp";
|
||||||
_BnpDirectory= NLMISC::CPath::standardizePath(_BnpDirectory,true);
|
_BnpDirectory = NLMISC::CPath::standardizePath(_BnpDirectory, true);
|
||||||
|
|
||||||
// ref directory
|
// ref directory
|
||||||
if (_RefDirectory.empty())
|
if (_RefDirectory.empty())
|
||||||
_RefDirectory= _RootDirectory+"ref";
|
_RefDirectory = _RootDirectory+"ref";
|
||||||
_RefDirectory= NLMISC::CPath::standardizePath(_RefDirectory,true);
|
_RefDirectory = NLMISC::CPath::standardizePath(_RefDirectory, true);
|
||||||
|
|
||||||
// client index file
|
// client index file
|
||||||
if (_ClientIndexFileName.empty())
|
if (_ClientIndexFileName.empty())
|
||||||
_ClientIndexFileName= NLMISC::CFile::getFilenameWithoutExtension(packageName)+".idx";
|
_ClientIndexFileName = NLMISC::CFile::getFilenameWithoutExtension(packageName)+".idx";
|
||||||
|
|
||||||
// index file
|
// index file
|
||||||
if (_IndexFileName.empty())
|
if (_IndexFileName.empty())
|
||||||
_IndexFileName= NLMISC::CFile::getFilenameWithoutExtension(_ClientIndexFileName)+".hist";
|
_IndexFileName = NLMISC::CFile::getFilenameWithoutExtension(_ClientIndexFileName)+".hist";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPackageDescription::storeToPdr(CPersistentDataRecord& pdr) const
|
void CPackageDescription::storeToPdr(CPersistentDataRecord& pdr) const
|
||||||
|
@ -348,14 +348,14 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
||||||
{
|
{
|
||||||
nlinfo("Generating patches ...");
|
nlinfo("Generating patches ...");
|
||||||
|
|
||||||
for (uint32 i=packageIndex.fileCount();i--;)
|
for (uint32 i = packageIndex.fileCount(); i--;)
|
||||||
{
|
{
|
||||||
bool deleteRefAfterDelta= true;
|
bool deleteRefAfterDelta = true;
|
||||||
bool usingTemporaryFile = false;
|
bool usingTemporaryFile = false;
|
||||||
// generate file name root
|
// generate file name root
|
||||||
std::string bnpFileName= _BnpDirectory+packageIndex.getFile(i).getFileName();
|
std::string bnpFileName = _BnpDirectory + packageIndex.getFile(i).getFileName();
|
||||||
std::string refNameRoot= _RefDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
std::string refNameRoot = _RefDirectory + NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||||
std::string patchNameRoot= _PatchDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
std::string patchNameRoot = _PatchDirectory + NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||||
|
|
||||||
// if the file has no versions then skip on to the next file
|
// if the file has no versions then skip on to the next file
|
||||||
if (packageIndex.getFile(i).versionCount()==0)
|
if (packageIndex.getFile(i).versionCount()==0)
|
||||||
|
@ -365,7 +365,7 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
||||||
const CBNPFileVersion& curVersion= packageIndex.getFile(i).getVersion(packageIndex.getFile(i).versionCount()-1);
|
const CBNPFileVersion& curVersion= packageIndex.getFile(i).getVersion(packageIndex.getFile(i).versionCount()-1);
|
||||||
std::string curVersionFileName= refNameRoot+NLMISC::toString("_%05u.%s",curVersion.getVersionNumber(),NLMISC::CFile::getExtension(bnpFileName).c_str());
|
std::string curVersionFileName= refNameRoot+NLMISC::toString("_%05u.%s",curVersion.getVersionNumber(),NLMISC::CFile::getExtension(bnpFileName).c_str());
|
||||||
// std::string patchFileName= patchNameRoot+NLMISC::toString("_%05d.patch",curVersion.getVersionNumber());
|
// std::string patchFileName= patchNameRoot+NLMISC::toString("_%05d.patch",curVersion.getVersionNumber());
|
||||||
std::string patchFileName= _PatchDirectory+toString("%05u/",curVersion.getVersionNumber())+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+toString("_%05u",curVersion.getVersionNumber())+".patch";
|
std::string patchFileName= _PatchDirectory + toString("%05u/",curVersion.getVersionNumber())+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+toString("_%05u",curVersion.getVersionNumber())+".patch";
|
||||||
|
|
||||||
// get the second last version number and the related file name
|
// get the second last version number and the related file name
|
||||||
std::string prevVersionFileName;
|
std::string prevVersionFileName;
|
||||||
|
@ -413,7 +413,7 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
||||||
refVersionFileName= _BnpDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+"_.ref";
|
refVersionFileName= _BnpDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+"_.ref";
|
||||||
|
|
||||||
// delete the previous patch - because we only need the latest patch for non-incremental files
|
// delete the previous patch - because we only need the latest patch for non-incremental files
|
||||||
std::string lastPatch= _PatchDirectory+NLMISC::CFile::getFilenameWithoutExtension(prevVersionFileName)+".patch";
|
std::string lastPatch= _PatchDirectory + NLMISC::CFile::getFilenameWithoutExtension(prevVersionFileName)+".patch";
|
||||||
if (NLMISC::CFile::fileExists(lastPatch.c_str()))
|
if (NLMISC::CFile::fileExists(lastPatch.c_str()))
|
||||||
NLMISC::CFile::deleteFile(lastPatch.c_str());
|
NLMISC::CFile::deleteFile(lastPatch.c_str());
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ static bool createNewProduct(std::string fileName)
|
||||||
pdr.writeToTxtFile(fileName);
|
pdr.writeToTxtFile(fileName);
|
||||||
|
|
||||||
BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to create new package file: "+fileName).c_str(),return false);
|
BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to create new package file: "+fileName).c_str(),return false);
|
||||||
nlinfo("New package description file created successfully: %s",fileName.c_str());
|
nlinfo("New package description file created successfully: %s", fileName.c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ NLMISC_COMMAND(listCharNames,"display the names of the characters int he listed
|
||||||
CStatsScanCharacter c;
|
CStatsScanCharacter c;
|
||||||
c.apply(pdr);
|
c.apply(pdr);
|
||||||
|
|
||||||
log.displayNL("%-40s Name: %s ",files[i].c_str(),c.EntityBase._Name.c_str());
|
log.displayNL("%-40s Name: %s ", files[i].c_str(), c.EntityBase._Name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue