mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 04:51:48 +00:00
Changed: Replace all path native functions by NeL methods
This commit is contained in:
parent
a8293233ed
commit
afbe840c51
13 changed files with 50 additions and 75 deletions
|
@ -132,15 +132,12 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di
|
|||
if (res)
|
||||
{
|
||||
// Path
|
||||
TCHAR sDrive[256];
|
||||
TCHAR sDir[256];
|
||||
_tsplitpath (sModulePath, sDrive, sDir, NULL, NULL);
|
||||
_tmakepath (sModulePath, sDrive, sDir, _T("ligoscape"), _T(".cfg"));
|
||||
std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath) + "ligoscape.cfg");
|
||||
|
||||
try
|
||||
{
|
||||
// Load the config file
|
||||
config.readConfigFile (tStrToUtf8(sModulePath), false);
|
||||
config.readConfigFile (path, false);
|
||||
|
||||
// ok
|
||||
return true;
|
||||
|
|
|
@ -262,8 +262,8 @@ Value* export_material_cf (Value** arg_list, int count)
|
|||
// Remove the files
|
||||
if (!ok)
|
||||
{
|
||||
remove (fileName);
|
||||
remove (path);
|
||||
CFile::deleteFile(fileName);
|
||||
CFile::deleteFile(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ Value* export_transition_cf (Value** arg_list, int count)
|
|||
for (uint file=0; file<createdfiles.size(); file++)
|
||||
{
|
||||
// Removing files
|
||||
remove (createdfiles[file].c_str ());
|
||||
CFile::deleteFile(createdfiles[file]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1991,8 +1991,7 @@ Value* make_snapshot_cf (Value** arg_list, int count)
|
|||
#if 0
|
||||
// Write the zone
|
||||
COFile outputLigoZone;
|
||||
std::string outputFilenameSnapShot = pathtga + nametga + ".tga";
|
||||
_makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".ligozone");
|
||||
std::string outputFilenameSnapShot = pathtga + nametga + ".ligozone";
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -93,8 +93,7 @@ using namespace NLPACS;
|
|||
|
||||
|
||||
|
||||
static char SDrive[256];
|
||||
static char SDir[256];
|
||||
static std::string SPath;
|
||||
|
||||
uint SkeletonUsedForSound = 0xFFFFFFFF;
|
||||
CSoundContext SoundContext;
|
||||
|
@ -285,9 +284,9 @@ std::string CObjectViewer::getModulePath() const
|
|||
int res = GetModuleFileName(hModule, sModulePath, 256); nlassert(res);
|
||||
nldebug("Object viewer module path is '%s'", sModulePath);
|
||||
|
||||
std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath));
|
||||
SPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath));
|
||||
|
||||
return NLMISC::CPath::standardizeDosPath(path) + "object_viewer.cfg";
|
||||
return SPath + "object_viewer.cfg";
|
||||
}
|
||||
|
||||
|
||||
|
@ -812,7 +811,6 @@ bool CObjectViewer::initUI (HWND parent)
|
|||
// Enable sum of vram
|
||||
CNELU::Driver->enableUsedTextureMemorySum ();
|
||||
|
||||
char sModulePath[256];
|
||||
// load the scheme bank if one is present
|
||||
CIFile iF;
|
||||
::_makepath (sModulePath, SDrive, SDir, "default", ".scb");
|
||||
|
@ -831,8 +829,9 @@ bool CObjectViewer::initUI (HWND parent)
|
|||
iF.close();
|
||||
|
||||
// try to load a default config file for the viewer (for anitmation and particle edition setup)
|
||||
::_makepath (sModulePath, SDrive, SDir, "default", ".ovcgf");
|
||||
if (iF.open (sModulePath))
|
||||
path = SPath + "default.ovcgf";
|
||||
|
||||
if (iF.open (path))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -36,17 +36,13 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
{
|
||||
// Result to return
|
||||
bool bRet = false;
|
||||
TCHAR tempFileName[MAX_PATH] = { 0 };
|
||||
TCHAR tempPathBuffer[MAX_PATH] = { 0 };
|
||||
std::string tempFileName;
|
||||
std::string tempPathBuffer;
|
||||
|
||||
try
|
||||
{
|
||||
DWORD dwRetVal = GetTempPath(MAX_PATH, tempPathBuffer);
|
||||
if (dwRetVal > MAX_PATH || (dwRetVal == 0))
|
||||
nlerror("GetTempPath failed");
|
||||
UINT uRetVal = GetTempFileName(tempPathBuffer, _T("_nel_export_mesh_"), 0, tempFileName);
|
||||
if (uRetVal == 0)
|
||||
nlerror("GetTempFileName failed");
|
||||
tempPathBuffer = NLMISC::CPath::getTemporaryDirectory();
|
||||
NLMISC::CFile::getTemporaryOutputFilename(tempPathBuffer + "_nel_export_mesh_", tempFileName);
|
||||
|
||||
// Eval the object a time
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
|
@ -99,7 +95,7 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
{
|
||||
// Open a file
|
||||
COFile file;
|
||||
if (file.open(tStrToUtf8(tempFileName)))
|
||||
if (file.open(tempFileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -126,12 +122,13 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
{
|
||||
|
||||
}
|
||||
remove(tempFileName);
|
||||
|
||||
CFile::deleteFile(tempFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Failed to create file %s", tempFileName);
|
||||
nlwarning("Failed to create file %s", tempFileName.c_str());
|
||||
if (_TerminateOnFileOpenIssues)
|
||||
nelExportTerminateProcess();
|
||||
}
|
||||
|
@ -148,7 +145,7 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
catch (...)
|
||||
{
|
||||
nlwarning("Failed to delete pShape pointer! Something might be wrong.");
|
||||
remove(tempFileName);
|
||||
CFile::deleteFile(tempFileName);
|
||||
bRet = false;
|
||||
}
|
||||
|
||||
|
@ -173,7 +170,7 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Failed to open file: %s", tempFileName);
|
||||
nlwarning("Failed to open file: %s", tempFileName.c_str());
|
||||
if (_TerminateOnFileOpenIssues)
|
||||
nelExportTerminateProcess();
|
||||
}
|
||||
|
@ -181,7 +178,7 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
catch (...)
|
||||
{
|
||||
nlwarning("Failed to verify shape. Must crash now.");
|
||||
remove(tempFileName);
|
||||
CFile::deleteFile(tempFileName);
|
||||
bRet = false;
|
||||
}
|
||||
|
||||
|
@ -196,16 +193,9 @@ bool CNelExport::exportMesh (const std::string &sPath, INode& node, TimeValue ti
|
|||
|
||||
if (bRet)
|
||||
{
|
||||
try
|
||||
{
|
||||
remove(sPath);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
CFile::deleteFile(sPath);
|
||||
CFile::moveFile(sPath, tempFileName);
|
||||
nlinfo("MOVE %s -> %s", tempFileName, sPath);
|
||||
nlinfo("MOVE %s -> %s", tempFileName.c_str(), sPath.c_str());
|
||||
}
|
||||
|
||||
return bRet;
|
||||
|
@ -250,17 +240,13 @@ bool CNelExport::exportAnim (const std::string &sPath, std::vector<INode*>& vect
|
|||
{
|
||||
// Result to return
|
||||
bool bRet=false;
|
||||
char tempFileName[MAX_PATH] = { 0 };
|
||||
char tempPathBuffer[MAX_PATH] = { 0 };
|
||||
std::string tempFileName;
|
||||
std::string tempPathBuffer;
|
||||
|
||||
try
|
||||
{
|
||||
DWORD dwRetVal = GetTempPathA(MAX_PATH, tempPathBuffer);
|
||||
if (dwRetVal > MAX_PATH || (dwRetVal == 0))
|
||||
nlerror("GetTempPath failed");
|
||||
UINT uRetVal = GetTempFileNameA(tempPathBuffer, TEXT("_nel_export_mesh_"), 0, tempFileName);
|
||||
if (uRetVal == 0)
|
||||
nlerror("GetTempFileName failed");
|
||||
tempPathBuffer = NLMISC::CPath::getTemporaryDirectory();
|
||||
NLMISC::CFile::getTemporaryOutputFilename(tempPathBuffer + "_nel_export_mesh_", tempFileName);
|
||||
|
||||
// Create an animation file
|
||||
CAnimation animFile;
|
||||
|
@ -269,7 +255,7 @@ bool CNelExport::exportAnim (const std::string &sPath, std::vector<INode*>& vect
|
|||
for (uint n=0; n<vectNode.size(); n++)
|
||||
{
|
||||
// Get name
|
||||
std::string nodeName="";
|
||||
std::string nodeName;
|
||||
|
||||
// Get NEL3D_APPDATA_EXPORT_ANIMATION_PREFIXE_NAME
|
||||
int prefixe = CExportNel::getScriptAppData (vectNode[n], NEL3D_APPDATA_EXPORT_ANIMATION_PREFIXE_NAME, 0);
|
||||
|
@ -327,7 +313,7 @@ bool CNelExport::exportAnim (const std::string &sPath, std::vector<INode*>& vect
|
|||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Failed to open file: %s", tempFileName);
|
||||
nlwarning("Failed to open file: %s", tempFileName.c_str());
|
||||
bRet = false;
|
||||
if (_TerminateOnFileOpenIssues)
|
||||
nelExportTerminateProcess();
|
||||
|
@ -336,7 +322,7 @@ bool CNelExport::exportAnim (const std::string &sPath, std::vector<INode*>& vect
|
|||
catch (...)
|
||||
{
|
||||
nlwarning("Failed to verify shape. Must crash now.");
|
||||
remove(tempFileName);
|
||||
CFile::deleteFile(tempFileName);
|
||||
bRet = false;
|
||||
}
|
||||
}
|
||||
|
@ -367,16 +353,9 @@ bool CNelExport::exportAnim (const std::string &sPath, std::vector<INode*>& vect
|
|||
|
||||
if (bRet)
|
||||
{
|
||||
try
|
||||
{
|
||||
remove(sPath);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
CFile::deleteFile(sPath);
|
||||
CFile::moveFile(sPath, tempFileName);
|
||||
nlinfo("MOVE %s -> %s", tempFileName, sPath);
|
||||
nlinfo("MOVE %s -> %s", tempFileName.c_str(), sPath.c_str());
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
|
|
@ -71,5 +71,6 @@ namespace std
|
|||
#endif
|
||||
|
||||
#include "nel/misc/bsphere.h"
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -895,12 +895,12 @@ void Browse::OnBatchLoad ()
|
|||
std::string ext = NLMISC::CFile::getExtension(fullPath);
|
||||
|
||||
// look for some numbers..
|
||||
char *sNumber=sName+strlen(sName)-1;
|
||||
while ((sNumber>sName)&&(*sNumber>='0')&&(*sNumber<='9'))
|
||||
std::string::size_type pos = filename.find_last_not_of("0123456789");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
sNumber--;
|
||||
filename = filename.substr(0, pos + 1);
|
||||
}
|
||||
sNumber[1]=0;
|
||||
|
||||
bool rotate=false;
|
||||
|
||||
|
@ -1396,7 +1396,7 @@ void Browse::OnExportBorder()
|
|||
try
|
||||
{
|
||||
COFile file;
|
||||
if (file.open ((const char*)pathName))
|
||||
if (file.open (tStrToUtf8(pathName)))
|
||||
{
|
||||
// Export
|
||||
bitmap.writeTGA (file, 32);
|
||||
|
@ -1439,7 +1439,7 @@ void Browse::OnImportBorder()
|
|||
try
|
||||
{
|
||||
CIFile file;
|
||||
if (file.open ((const char*)pathName))
|
||||
if (file.open (tStrToUtf8(pathName)))
|
||||
{
|
||||
// Export
|
||||
bitmap.load (file);
|
||||
|
|
|
@ -434,7 +434,7 @@ void CTile_browser_dlg::on_batchLoadPushButton_clicked()
|
|||
QString batchNumber = transitionNumber.rightJustified(2, '0');
|
||||
QString nextBaseName = baseName + batchNumber;
|
||||
QString nextFileName = QDir::toNativeSeparators(fi.absolutePath()) + QDir::separator() + nextBaseName + QString(".") + fi.suffix();
|
||||
FILE *pFile=fopen (nextFileName.toUtf8().constData(), "rb");
|
||||
FILE *pFile = nlfopen (nextFileName.toUtf8().constData(), "rb");
|
||||
|
||||
// Close the file and add the tile if opened
|
||||
if (pFile)
|
||||
|
@ -471,8 +471,7 @@ void CTile_browser_dlg::on_batchLoadPushButton_clicked()
|
|||
// char sName2[256];
|
||||
// char sFinal[256];
|
||||
// sprintf (sName2, "%s%02d", sName, (int)transition);
|
||||
// _makepath (sFinal, sDrive, sPath, sName2, sExt);
|
||||
// FILE *pFile=fopen (sFinal, "rb");
|
||||
// FILE *pFile = nlfopen (sFinal, "rb");
|
||||
|
||||
// // Close the file and add the tile if opened
|
||||
// if (pFile)
|
||||
|
|
|
@ -522,7 +522,7 @@ int main (int argc, char* argv[])
|
|||
|
||||
// Write the dependencies file
|
||||
FILE *outputFile;
|
||||
if ((outputFile=fopen (toLower (outputFileName).c_str(), "w")))
|
||||
if ((outputFile = nlfopen (toLower (outputFileName), "w")))
|
||||
{
|
||||
// Add a dependency entry
|
||||
fprintf (outputFile, "dependencies =\n{\n");
|
||||
|
|
|
@ -179,7 +179,7 @@ void setOutputFile(const CSString &filename)
|
|||
{
|
||||
if (Outf!=NULL)
|
||||
fclose(Outf);
|
||||
Outf=fopen(filename.c_str(), "wt");
|
||||
Outf = nlfopen(filename.c_str(), "wt");
|
||||
if (Outf == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't open output file '%s' ! aborting.", filename.c_str());
|
||||
|
|
|
@ -548,7 +548,7 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|||
|
||||
if (!extLower.empty ())
|
||||
{
|
||||
string dfnName = extLower.substr (1, string::npos) + ".dfn";
|
||||
string dfnName = extLower + ".dfn";
|
||||
|
||||
// Check if the file is handled
|
||||
if (theApp.getFormDocTemplate (dfnName.c_str ()) == NULL)
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
// Include from libxml2
|
||||
#include <libxml/parser.h>
|
||||
|
|
|
@ -1115,7 +1115,7 @@ int main (int argc, char**argv)
|
|||
outString ("REMOVE " + CFile::getFilename (igFilename) + " \n");
|
||||
|
||||
// Remove it
|
||||
if (remove (igFilename.c_str ()) != 0)
|
||||
if (!CFile::deleteFile(igFilename))
|
||||
{
|
||||
// Error in the log
|
||||
nlwarning ("Error : Can't remove the file (%s)", igFilename.c_str ());
|
||||
|
|
|
@ -52,7 +52,7 @@ CCharacterScanJob::CCharacterScanJob()
|
|||
|
||||
// open the output file for the character table
|
||||
std::string filename= "char_tbl.csv";
|
||||
_CharTblFile=fopen(filename.c_str(),"wb");
|
||||
_CharTblFile = nlfopen(filename, "wb");
|
||||
if (_CharTblFile==NULL)
|
||||
{
|
||||
nlwarning("Failed to open output file: %s",filename.c_str());
|
||||
|
@ -73,7 +73,7 @@ CCharacterScanJob::~CCharacterScanJob()
|
|||
{
|
||||
// create the output file name and open the file for writing
|
||||
std::string filename="char_stats_"+(*it).first+".csv";
|
||||
FILE* f=fopen(filename.c_str(),"wb");
|
||||
FILE* f = nlfopen(filename, "wb");
|
||||
if (f==NULL)
|
||||
{
|
||||
nlwarning("Failed to open output file: %s",filename.c_str());
|
||||
|
|
Loading…
Reference in a new issue