void CCrashHandler::Init ( const SString& strInServerPath ) { SString strServerPath = strInServerPath; if ( strServerPath == "" ) strServerPath = GetSystemCurrentDirectory(); ms_strDumpPath = PathJoin( strServerPath, SERVER_DUMP_PATH ); // Set a global filter #ifdef WIN32 SetCrashHandlerFilter ( HandleExceptionGlobal ); #else // Prepare initial dumpfile name time_t pTime = time( NULL ); struct tm* tm = localtime( &pTime ); SString strFilename( "server_%s_%04d%02d%02d_%02d%02d.dmp", MTA_DM_BUILDTAG_LONG, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min ); ms_strDumpPathFilename = PathJoin( ms_strDumpPath, strFilename ); MakeSureDirExists( ms_strDumpPathFilename ); #ifdef WITH_BACKTRACE_ONLY signal ( SIGSEGV, HandleExceptionGlobal ); #else google_breakpad::MinidumpDescriptor descriptor( ms_strDumpPath ); static google_breakpad::ExceptionHandler eh( descriptor, NULL, DumpCallback, NULL, true, -1 ); #endif #endif }
int CLuaFileDefs::fileDelete ( lua_State* luaVM ) { // bool fileDelete ( string filePath ) SString strFile; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strFile ); if ( argStream.NextIsUserData () ) m_pScriptDebugging->LogCustom ( luaVM, "fileDelete may be using an outdated syntax. Please check and update." ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { std::string strPath; // We have a resource argument? CResource* pThisResource = pLuaMain->GetResource (); CResource* pResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( strFile, pResource, &strPath, NULL ) ) { // Do we have permissions? if ( pResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { // Make sure the dir exists so we can remove the file MakeSureDirExists ( strPath.c_str () ); if ( remove ( strPath.c_str () ) == 0 ) { // If file removed return success lua_pushboolean ( luaVM, true ); return 1; } else { // Output error m_pScriptDebugging->LogWarning ( luaVM, "%s; unable to delete file", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ) ); } } else m_pScriptDebugging->LogError ( luaVM, "%s failed; ModifyOtherObjects in ACL denied resource %s to access %s", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), pThisResource->GetName ().c_str (), pResource->GetName ().c_str () ); } } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
void SharedUtil::AddReportLog ( uint uiId, const SString& strText ) { SString strPathFilename = PathJoin ( GetMTADataPath (), "report.log" ); MakeSureDirExists ( strPathFilename ); SString strMessage ( "%u: %s %s - %s\n", uiId, GetTimeString ( true, false ).c_str (), GetReportLogHeaderText ().c_str (), strText.c_str () ); FileAppend ( strPathFilename, &strMessage.at ( 0 ), strMessage.length () ); #if MTA_DEBUG OutputDebugLine ( SStringX ( "[ReportLog] " ) + strMessage ); #endif }
bool Converter::MakeSureDirExists(wxFileName& path) { wxFileName parent(path); parent.RemoveLastDir(); if (parent.GetDirCount() > 0 && !parent.DirExists()) { if (!MakeSureDirExists(parent)) { return false; } } if (!path.DirExists()) { return path.Mkdir(); } return true; }
void CCrashHandler::HandleExceptionGlobal ( int iSig ) { MakeSureDirExists ( "dumps/" ); // Collect backtrace information void * buffer [ 100 ]; int iAmount = backtrace ( buffer, sizeof buffer ); char ** symbols = backtrace_symbols ( buffer, iAmount ); // Generate a .log file time_t pTime = time ( NULL ); struct tm * tm = localtime ( &pTime ); SString sFileName; sFileName.Format ( "dumps/server_%s_%04d%02d%02d_%02d%02d.log", MTA_DM_BUILDTYPE, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min ); SString sContent; sContent += SString ( "MTA:SA Server v%s-r%d-%s crash report.\n", MTA_DM_VERSIONSTRING, MTASA_VERSION_BUILD, MTA_DM_BUILDTYPE ); sContent += SString ( "%04d-%02d-%02d %02d:%02d\n", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min ); sContent += SString ( "Caught %d addresses ...\n\n", iAmount ); sContent += "Backtrace:\n"; for ( int i = 0; i < iAmount; i++ ) { if ( symbols [ i ] ) { sContent += SString ( "#%d - %s\n", i, symbols [ i ] ); } } sContent += std::string( 80, '-' ) + "\n"; // Write the content to the file and close FileAppend( sFileName, sContent ); FileAppend( "dumps/server_pending_upload.log", sContent ); free ( symbols ); // Try to close window gracefully if ( !g_bSilent && !g_bNoCurses && m_wndInput ) { if ( m_wndMenu ) { delwin ( m_wndMenu ); m_wndMenu = NULL; } delwin ( m_wndInput ); m_wndInput = NULL; endwin ( ); } exit ( EXIT_FAILURE ); }
void Converter::ConvertPhoto(Photo& photo, const wxString& root, const wxString& group_name, const wxString& extension) { boost::scoped_ptr<Bitmap> bitmap(Bitmap::Read(photo.m_path.GetFullPath())); wxFileName output_path(root, photo.m_path.GetName()); output_path.MakeAbsolute(); output_path.AppendDir(group_name); output_path.SetExt(extension); if (!MakeSureDirExists(output_path)) { m_listener.OnConvertFail(photo); return; } if (bitmap.get() == NULL) { m_listener.OnConvertFail(photo); return; } if (!photo.IsSizeSet()) { photo.m_size = bitmap->GetSize(); } // wxRect rect = m_project.HasPhotoCrop(photo) ? // m_project.GetPhotoCrop(photo) : // wxRect(wxPoint(-1, -1), m_project.GetResizer().GetSize(photo.m_size)); // if (wxPoint(-1, -1) == rect.GetPosition()) { // bitmap->Scale(rect.GetSize()); // } else { // bitmap->Crop(rect); // } const Resizer& resizer = m_project.GetResizer(); if (resizer.NeedsCrop(photo.m_size)) { wxRect crop = m_project.HasPhotoCrop(photo) ? m_project.GetPhotoCrop(photo) : wxRect(wxPoint(0, 0), resizer.GetCropSize(photo.m_size)); bitmap->Crop(crop); } if (resizer.NeedsRescale(photo.m_size)) { bitmap->Scale(resizer.GetScaleSize(photo.m_size)); } if (!bitmap->Write(output_path.GetFullPath())) { m_listener.OnConvertFail(photo); return; } Photo dest(output_path.GetFullPath()); dest.m_size = bitmap->GetSize(); m_listener.OnConvertSuccess(photo, dest); // Log::d << "ConvertPhoto to [" << output_path.GetFullPath() << "]." << Log::ENDL; }
static void SaveBacktraceSummary() { // Collect backtrace information void * buffer [ 100 ]; int iAmount = backtrace ( buffer, sizeof buffer ); iAmount = std::min < int > ( iAmount, NUMELMS( buffer ) ); char ** symbols = backtrace_symbols ( buffer, iAmount ); // Generate a .log file time_t pTime = time ( NULL ); struct tm * tm = localtime ( &pTime ); SString sFileName; sFileName.Format ( "server_%s_%04d%02d%02d_%02d%02d.log", MTA_DM_BUILDTYPE, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min ); SString sContent; sContent += SString ( "MTA:SA Server v%s-r%d-%s crash report.\n", MTA_DM_VERSIONSTRING, MTASA_VERSION_BUILD, MTA_DM_BUILDTYPE ); sContent += SString ( "%04d-%02d-%02d %02d:%02d\n", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min ); sContent += SString ( "Caught %d addresses ...\n\n", iAmount ); sContent += "Backtrace:\n"; for ( int i = 0; i < iAmount; i++ ) { if ( symbols [ i ] ) { sContent += SString ( "#%d - %s\n", i, symbols [ i ] ); } } sContent += std::string( 80, '-' ) + "\n"; // Write the content to the file and close MakeSureDirExists ( PathJoin( ms_strDumpPath, sFileName ) ); FileAppend( PathJoin( ms_strDumpPath, sFileName ), sContent ); FileAppend( PathJoin( ms_strDumpPath, "server_pending_upload.log" ), sContent ); free ( symbols ); // Try to close window gracefully if ( !g_bSilent && !g_bNoCurses && m_wndInput ) { if ( m_wndMenu ) { delwin ( m_wndMenu ); m_wndMenu = NULL; } delwin ( m_wndInput ); m_wndInput = NULL; endwin ( ); } }
/////////////////////////////////////////////////////////////// // // CServerIdManagerImpl::CServerIdManagerImpl // // // /////////////////////////////////////////////////////////////// CServerIdManagerImpl::CServerIdManagerImpl ( void ) { // Calc private dir root m_strServerIdLookupBaseDir = PathJoin ( g_pClientGame->GetFileCacheRoot(), MTA_SERVERID_LOOKUP_DIR ); MakeSureDirExists ( PathJoin ( m_strServerIdLookupBaseDir, "" ) ); // Calc temp dir path incase of server id error m_strTempErrorDir = PathJoin ( m_strServerIdLookupBaseDir, "_error" ); // If temp dir has been used, clean it if ( DirectoryExists ( m_strTempErrorDir ) ) DelTree ( m_strTempErrorDir, m_strServerIdLookupBaseDir ); LoadServerIdMap (); }
/////////////////////////////////////////////////////////////// // // CDatabaseConnectionSqlite::CDatabaseConnectionSqlite // // // /////////////////////////////////////////////////////////////// CDatabaseConnectionSqlite::CDatabaseConnectionSqlite ( CDatabaseType* pManager, const SString& strPath, const SString& strOptions ) : m_iRefCount ( 1 ) , m_pManager ( pManager ) { g_pStats->iDbConnectionCount++; // Parse options string GetOption < CDbOptionsMap > ( strOptions, "batch", m_bAutomaticTransactionsEnabled, 1 ); MakeSureDirExists ( strPath ); if ( sqlite3_open ( strPath, &m_handle ) ) { SetLastError ( sqlite3_errcode ( m_handle ), sqlite3_errmsg ( m_handle ) ); } else { m_bOpened = true; } }
// // Save binary data to a file // bool SharedUtil::FileSave ( const SString& strFilename, const void* pBuffer, unsigned long ulSize, bool bForce ) { #ifdef WIN32 if ( bForce ) SetFileAttributes ( strFilename, FILE_ATTRIBUTE_NORMAL ); #endif if ( bForce ) MakeSureDirExists ( strFilename ); FILE* fh = fopen ( strFilename, "wb" ); if ( !fh ) return false; bool bSaveOk = true; if ( ulSize ) bSaveOk = ( fwrite ( pBuffer, 1, ulSize, fh ) == ulSize ); fclose ( fh ); return bSaveOk; }
void CCrashHandler::HandleExceptionGlobal ( int iSig ) { MakeSureDirExists ( "dumps/" ); // Collect backtrace information void * buffer [ 100 ]; int iAmount = backtrace ( buffer, sizeof buffer ); char ** symbols = backtrace_symbols ( buffer, iAmount ); // Generate a .log file time_t pTime = time ( NULL ); struct tm * tm = localtime ( &pTime ); SString sFileName; sFileName.Format ( "dumps/server_%s_%04d%02d%02d_%02d%02d.log", MTA_DM_BUILDTYPE, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min ); FILE * pFile = fopen ( sFileName.c_str ( ), "w" ); if ( pFile ) { SString sContent; sContent += SString ( "MTA:SA Server v%s-r%d-%s crash report.\n", MTA_DM_VERSIONSTRING, MTASA_VERSION_BUILD, MTA_DM_BUILDTYPE ); sContent += SString ( "Caught %d addresses ...\n\n", iAmount ); sContent += "Backtrace:\n"; for ( int i = 0; i < iAmount; i++ ) { if ( symbols [ i ] ) { sContent += SString ( "#%d - %s\n", i, symbols [ i ] ); } } // Write the content to the file and close fprintf ( pFile, sContent.c_str ( ) ); fclose ( pFile ); } free ( symbols ); exit ( EXIT_FAILURE ); }
bool CScriptFile::Load ( eMode Mode ) { // If we haven't already got a file if ( !m_pFile ) { string strFilePath; switch ( Mode ) { // Open file in read only binary mode case MODE_READ: if ( m_pResource->GetFilePath ( m_strFilename.c_str(), strFilePath ) ) m_pFile = fopen ( strFilePath.c_str (), "rb" ); break; // Open file in read write binary mode. case MODE_READWRITE: // Try to load the file in rw mode. Use existing content. if ( m_pResource->GetFilePath ( m_strFilename.c_str(), strFilePath ) ) m_pFile = fopen ( strFilePath.c_str (), "rb+" ); break; // Open file in read write binary mode. Truncate size to 0. case MODE_CREATE: strFilePath = m_pResource->GetResourceDirectoryPath () + m_strFilename; MakeSureDirExists ( strFilePath.c_str () ); m_pFile = fopen ( strFilePath.c_str (), "wb+" ); break; } // Return whether we successfully opened it or not return m_pFile != NULL; } // Failed return false; }
/////////////////////////////////////////////////////////////// // // FileCopy // // Copies a single file. // /////////////////////////////////////////////////////////////// bool SharedUtil::FileCopy ( const SString& strSrc, const SString& strDest, bool bForce ) { if ( bForce ) MakeSureDirExists ( strDest ); #ifdef WIN32 if ( bForce ) SetFileAttributes ( strDest, FILE_ATTRIBUTE_NORMAL ); #endif FILE* fhSrc = fopen ( strSrc, "rb" ); if ( !fhSrc ) { return false; } FILE* fhDst = fopen ( strDest, "wb" ); if ( !fhDst ) { fclose ( fhSrc ); return false; } char cBuffer[65536]; while ( true ) { size_t dataLength = fread ( cBuffer, 1, 65536, fhSrc ); if ( dataLength == 0 ) break; fwrite ( cBuffer, 1, dataLength, fhDst ); } fclose ( fhSrc ); fclose ( fhDst ); return true; }
int CLuaXMLDefs::xmlCreateFile ( lua_State* luaVM ) { #ifndef MTA_CLIENT if ( lua_type ( luaVM, 3 ) == LUA_TLIGHTUSERDATA ) m_pScriptDebugging->LogCustom ( luaVM, "xmlCreateFile may be using an outdated syntax. Please check and update." ); #endif // !MTA_CLIENT // Grab our resource CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { SString strInputPath, strRootNodeName; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strInputPath ); argStream.ReadString ( strRootNodeName ); if ( !argStream.HasErrors () ) { SString strPath; CResource* pThisResource = pLuaMain->GetResource (); CResource* pOtherResource = pThisResource; // clientside, this variable will always be pThisResource // Resolve other resource from name if ( CResourceManager::ParseResourcePathInput ( strInputPath, pOtherResource, &strPath, nullptr ) ) { #ifndef MTA_CLIENT // We have access to modify other resource? if ( pOtherResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) #endif // !MTA_CLIENT { // Make sure the dir exists so we can successfully make the file MakeSureDirExists ( strPath ); // Create the XML file CXMLFile * xmlFile = pLuaMain->CreateXML ( strPath ); if ( xmlFile ) { // Create its root node CXMLNode* pRootNode = xmlFile->CreateRootNode ( strRootNodeName ); if ( pRootNode ) { lua_pushxmlnode ( luaVM, pRootNode ); return 1; } // Destroy it if we failed pLuaMain->DestroyXML ( xmlFile ); } } #ifndef MTA_CLIENT else argStream.SetCustomError ( SString ( "ModifyOtherObjects in ACL denied resource '%s' to access '%s'", pThisResource->GetName ().c_str (), pOtherResource->GetName ().c_str () ), "Access denied" ); #endif // !MTA_CLIENT } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); } lua_pushboolean ( luaVM, false ); return 1; }
int CLuaXMLDefs::xmlCopyFile ( lua_State* luaVM ) { #ifndef MTA_CLIENT if ( lua_type ( luaVM, 3 ) == LUA_TLIGHTUSERDATA ) m_pScriptDebugging->LogCustom ( luaVM, "xmlCopyFile may be using an outdated syntax. Please check and update." ); #endif // !MTA_CLIENT // Grab our resource CLuaMain* pLUA = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLUA ) { SString strFile; CXMLNode* pSourceNode; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pSourceNode ); argStream.ReadString ( strFile ); if ( !argStream.HasErrors () ) { SString strPath; CResource* pThisResource = pLUA->GetResource (); CResource* pOtherResource = pThisResource; // Resolve other resource from name if ( CResourceManager::ParseResourcePathInput ( strFile, pOtherResource, &strPath, NULL ) ) { #ifndef MTA_CLIENT // We have access to modify other resource? if ( pOtherResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) #endif // !MTA_CLIENT { if ( pSourceNode ) { // Make sure the dir exists so we can successfully make the file MakeSureDirExists ( strPath ); // Grab the roots tag name std::string strRootTagName; strRootTagName = pSourceNode->GetTagName (); // Create the new XML file and its root node CXMLFile* pNewXML = pLUA->CreateXML ( strPath.c_str () ); if ( pNewXML ) { // Grab the root of the new XML CXMLNode* pNewRoot = pNewXML->CreateRootNode ( strRootTagName ); if ( pNewRoot ) { // Copy over the attributes from the root int iAttributeCount = pSourceNode->GetAttributes ().Count (); int i = 0; CXMLAttribute* pAttribute; for ( ; i < iAttributeCount; i++ ) { pAttribute = pSourceNode->GetAttributes ().Get ( i ); if ( pAttribute ) pNewRoot->GetAttributes ().Create ( *pAttribute ); } // Copy the stuff from the given source node to the destination root if ( pSourceNode->CopyChildrenInto ( pNewRoot, true ) ) { lua_pushxmlnode ( luaVM, pNewRoot ); return 1; } } // Delete the XML again pLUA->DestroyXML ( pNewXML ); } } else argStream.SetCustomError ( SString ( "Unable to copy XML file %s", strFile.c_str () ), "Bad filepath" ); } #ifndef MTA_CLIENT else argStream.SetCustomError ( SString ( "ModifyOtherObjects in ACL denied resource '%s' to access '%s'", pThisResource->GetName ().c_str (), pOtherResource->GetName ().c_str () ), "Access denied" ); #endif } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); } // Error lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileCopy ( lua_State* luaVM ) { // bool fileCopy ( string filePath, string newFilePath, bool overwrite = false ) SString filePath; SString newFilePath; bool bOverwrite; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( filePath ); argStream.ReadString ( newFilePath ); argStream.ReadBool ( bOverwrite, false ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( !g_pNet->ValidateBinaryFileName ( newFilePath ) ) { argStream.SetCustomError ( SString ( "Filename not allowed %s", *newFilePath ), "File error" ); } else if ( pLuaMain ) { std::string strCurAbsPath; std::string strNewAbsPath; // We have a resource arguments? CResource* pThisResource = pLuaMain->GetResource (); CResource* pCurResource = pThisResource; CResource* pNewResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( filePath, pCurResource, strCurAbsPath ) && CResourceManager::ParseResourcePathInput ( newFilePath, pNewResource, strNewAbsPath ) ) { // Does source file exist? if ( FileExists ( strCurAbsPath ) ) { // Does destination file exist? if ( !bOverwrite && FileExists ( strNewAbsPath ) ) { argStream.SetCustomError ( SString ( "Destination file already exists (%s)", *newFilePath ), "File error" ); } else { // Inform file verifier g_pClientGame->GetResourceManager()->FileModifedByScript( strNewAbsPath ); // Make sure the destination folder exists so we can copy the file MakeSureDirExists ( strNewAbsPath ); if ( FileCopy ( strCurAbsPath, strNewAbsPath ) ) { // If file copied return success lua_pushboolean ( luaVM, true ); return 1; } else { argStream.SetCustomError ( SString ( "Unable to copy %s to %s", *filePath, *newFilePath ), "File error" ); } } } else { argStream.SetCustomError ( SString ( "Source file doesn't exist (%s)", *filePath ), "File error" ); } } } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileCreate ( lua_State* luaVM ) { // file fileCreate ( string filePath ) SString filePath; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( filePath ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( !g_pNet->ValidateBinaryFileName ( filePath ) ) { argStream.SetCustomError ( SString ( "Filename not allowed %s", *filePath ), "File error" ); } else if ( pLuaMain ) { SString strAbsPath; SString strMetaPath; CResource* pThisResource = pLuaMain->GetResource (); CResource* pResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( filePath, pResource, strAbsPath, strMetaPath ) ) { // Inform file verifier g_pClientGame->GetResourceManager()->FileModifedByScript( strAbsPath ); // Make sure the destination folder exist so we can create the file MakeSureDirExists ( strAbsPath.c_str () ); // Create the file to create eAccessType accessType = filePath[0] == '@' ? eAccessType::ACCESS_PRIVATE : eAccessType::ACCESS_PUBLIC; CScriptFile* pFile = new CScriptFile( pThisResource->GetScriptID( ), strMetaPath.c_str(), DEFAULT_MAX_FILESIZE, accessType); assert ( pFile ); // Try to load it if ( pFile->Load ( pResource, CScriptFile::MODE_CREATE ) ) { // Make it a child of the resource's file root pFile->SetParent ( pResource->GetResourceDynamicEntity () ); // Add it to the scrpt resource element group CElementGroup* pGroup = pThisResource->GetElementGroup (); if ( pGroup ) { pGroup->Add ( pFile ); } // Success. Return the file. lua_pushelement ( luaVM, pFile ); return 1; } else { // Delete the file again delete pFile; // Output error argStream.SetCustomError ( SString ( "Unable to create %s", *filePath ), "File error" ); } } } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
void SharedUtil::SetReportLogContents ( const SString& strText ) { SString strPathFilename = PathJoin ( GetMTADataPath (), "report.log" ); MakeSureDirExists ( strPathFilename ); FileSave ( strPathFilename, strText.length () ? &strText.at ( 0 ) : NULL, strText.length () ); }
int CLuaXMLDefs::xmlLoadFile ( lua_State* luaVM ) { if ( lua_type ( luaVM, 2 ) == LUA_TLIGHTUSERDATA ) m_pScriptDebugging->LogCustom ( luaVM, "xmlLoadFile may be using an outdated syntax. Please check and update." ); // Grab our resource CLuaMain* pLUA = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLUA ) { CResource* pThisResource = pLUA->GetResource (); CResource* pResource = pThisResource; // Filename if ( lua_type ( luaVM, 1 ) != LUA_TSTRING ) { m_pScriptDebugging->LogBadType ( luaVM, "xmlLoadFile" ); lua_pushboolean ( luaVM, false ); return 1; } // Grab the filename passed std::string strFile = lua_tostring ( luaVM, 1 ); std::string strPath; if ( CResourceManager::ParseResourcePathInput ( strFile, pResource, &strPath, NULL ) ) { if ( pResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { // Make sure the dir exists so we can successfully make the file MakeSureDirExists ( strPath.c_str () ); // Create the XML CXMLFile* xmlFile = pLUA->CreateXML ( strPath.c_str () ); if ( xmlFile ) { // Try to parse it if ( xmlFile->Parse () ) { // Grab the root node. If it didn't exist, create one CXMLNode * pRootNode = xmlFile->GetRootNode (); if ( !pRootNode ) pRootNode = xmlFile->CreateRootNode ( "root" ); // Could we create one? if ( pRootNode ) { // Return the root node lua_pushxmlnode ( luaVM, pRootNode ); return 1; } } // Destroy it if we failed pLUA->DestroyXML ( xmlFile ); } } else m_pScriptDebugging->LogError ( luaVM, "xmlLoadFile failed; ModifyOtherObjects in ACL denied resource %s to access %s", pThisResource->GetName ().c_str (), pResource->GetName ().c_str () ); } } lua_pushboolean ( luaVM, false ); return 1; }
int CLuaXMLDefs::xmlCopyFile ( lua_State* luaVM ) { if ( lua_type ( luaVM, 3 ) == LUA_TLIGHTUSERDATA ) m_pScriptDebugging->LogCustom ( luaVM, "xmlCopyFile may be using an outdated syntax. Please check and update." ); // Grab our resource CLuaMain* pLUA = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLUA ) { CResource* pThisResource = pLUA->GetResource (); CResource* pResource = pThisResource; // Verify the argument types passed if ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA && lua_type ( luaVM, 2 ) == LUA_TSTRING ) { // Grab the filename passed std::string strFile = lua_tostring ( luaVM, 2 ); std::string strPath; if ( CResourceManager::ParseResourcePathInput ( strFile, pResource, &strPath, NULL ) ) { // We have access to modify this resource? if ( pResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { // Make sure the dir exists so we can successfully make the file MakeSureDirExists ( strPath.c_str () ); // Grab the source node CXMLNode* pSourceNode = lua_toxmlnode ( luaVM, 1 ); if ( pSourceNode ) { // Grab the roots tag name std::string strRootTagName; strRootTagName = pSourceNode->GetTagName (); // Create the new XML file and its root node CXMLFile* pNewXML = pLUA->CreateXML ( strPath.c_str () ); if ( pNewXML ) { // Grab the root of the new XML CXMLNode* pNewRoot = pNewXML->CreateRootNode ( strRootTagName ); if ( pNewRoot ) { // Copy over the attributes from the root int iAttributeCount = pSourceNode->GetAttributes ().Count (); int i = 0; CXMLAttribute* pAttribute; for ( ; i < iAttributeCount; i++ ) { pAttribute = pSourceNode->GetAttributes ().Get ( i ); if ( pAttribute ) pNewRoot->GetAttributes ().Create ( *pAttribute ); } // Copy the stuff from the given source node to the destination root if ( pSourceNode->CopyChildrenInto ( pNewRoot, true ) ) { lua_pushxmlnode ( luaVM, pNewRoot ); return 1; } } // Delete the XML again pLUA->DestroyXML ( pNewXML ); } } else CLogger::ErrorPrintf ( "Unable to copy xml file; bad filepath" ); } else m_pScriptDebugging->LogError ( luaVM,"xmlCopyFile failed; ModifyOtherObjects in ACL denied resource %s to access %s", pThisResource->GetName ().c_str (), pResource->GetName ().c_str () ); } } else m_pScriptDebugging->LogBadType ( luaVM, "xmlCopyFile" ); } // Error lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileCopy ( lua_State* luaVM ) { // bool fileCopy ( string filePath, string newFilePath, bool overwrite = false ) SString filePath; SString newFilePath; bool bOverwrite; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( filePath ); argStream.ReadString ( newFilePath ); argStream.ReadBool ( bOverwrite, false ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { std::string strCurAbsPath; std::string strNewAbsPath; std::string strCurMetaPath; std::string strNewMetaPath; // We have a resource arguments? CResource* pThisResource = pLuaMain->GetResource (); CResource* pCurResource = pThisResource; CResource* pNewResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( filePath, pCurResource, &strCurAbsPath, &strCurMetaPath ) && CResourceManager::ParseResourcePathInput ( newFilePath, pNewResource, &strNewAbsPath, &strNewMetaPath ) ) { // Do we have permissions? if ( ( pCurResource == pThisResource && pNewResource == pThisResource ) || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { std::string strCurFilePath; // Same as strCurAbsPath std::string strNewFilePath; // Same as strNewAbsPath // Does source file exist? if ( pCurResource->GetFilePath ( strCurMetaPath.c_str(), strCurFilePath ) ) { // Does destination file exist? if ( !bOverwrite && pNewResource->GetFilePath ( strNewMetaPath.c_str(), strNewFilePath ) ) { argStream.SetCustomError ( SString ( "Destination file already exists (%s)", *newFilePath ), "File error" ); } else { // Make sure the destination folder exists so we can copy the file MakeSureDirExists ( strNewAbsPath ); if ( FileCopy ( strCurAbsPath, strNewAbsPath ) ) { // If file copied return success lua_pushboolean ( luaVM, true ); return 1; } else { argStream.SetCustomError ( SString ( "Unable to copy %s to %s", *filePath, *newFilePath ), "File error" ); } } } else { argStream.SetCustomError ( SString ( "Source file doesn't exist (%s)", *filePath ), "File error" ); } } else { // Make permissions error message SString strWho; if ( pThisResource != pCurResource ) strWho += pCurResource->GetName (); if ( pThisResource != pNewResource ) { if ( !strWho.empty () ) strWho += " and "; strWho += pNewResource->GetName (); } argStream.SetCustomError ( SString ( "ModifyOtherObjects in ACL denied resource %s to access %s", pThisResource->GetName ().c_str (), *strWho ), "ACL issue" ); } } } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileCreate ( lua_State* luaVM ) { // file fileCreate ( string filePath ) SString strFile; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strFile ); if ( argStream.NextIsUserData () ) m_pScriptDebugging->LogCustom ( luaVM, "fileCreate may be using an outdated syntax. Please check and update." ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { // Grab the filename std::string strAbsPath; std::string strSubPath; // We have a resource argument? CResource* pThisResource = pLuaMain->GetResource (); CResource* pResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( strFile, pResource, &strAbsPath, &strSubPath ) ) { // Do we have permissions? if ( pResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { // Make sure the destination folder exist so we can create the file MakeSureDirExists ( strAbsPath.c_str () ); // Create the file to create CScriptFile* pFile = new CScriptFile ( pThisResource->GetScriptID(), strSubPath.c_str (), DEFAULT_MAX_FILESIZE ); assert ( pFile ); // Try to load it if ( pFile->Load ( pResource, CScriptFile::MODE_CREATE ) ) { // Add it to the scrpt resource element group CElementGroup* pGroup = pThisResource->GetElementGroup (); if ( pGroup ) { pGroup->Add ( pFile ); } // Success. Return the file. lua_pushelement ( luaVM, pFile ); return 1; } else { // Delete the file again delete pFile; // Output error m_pScriptDebugging->LogWarning ( luaVM, "%s; unable to load file", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ) ); } } else m_pScriptDebugging->LogError ( luaVM, "%s failed; ModifyOtherObjects in ACL denied resource %s to access %s", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), pThisResource->GetName ().c_str (), pResource->GetName ().c_str () ); } } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
int CLuaFileDefs::fileRename ( lua_State* luaVM ) { // bool fileRename ( string filePath, string newFilePath ) SString strCurFile; SString strNewFile; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strCurFile ); argStream.ReadString ( strNewFile ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLuaMain ) { std::string strCurPath; std::string strNewPath; std::string strCurSubPath; std::string strNewSubPath; // We have a resource arguments? CResource* pThisResource = pLuaMain->GetResource (); CResource* pCurResource = pThisResource; CResource* pNewResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( strCurFile, pCurResource, &strCurPath, &strCurSubPath ) && CResourceManager::ParseResourcePathInput ( strNewFile, pNewResource, &strNewPath, &strNewSubPath ) ) { // Do we have permissions? if ( ( pCurResource == pThisResource && pNewResource == pThisResource ) || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { string strCurFilePath; string strNewFilePath; // Does `current` file path exist and `new` file path doesn't exist? if ( pCurResource->GetFilePath ( strCurSubPath.c_str(), strCurFilePath ) && !pNewResource->GetFilePath ( strNewSubPath.c_str(), strNewFilePath ) ) { // Make sure the destination folder exist so we can move the file MakeSureDirExists ( strNewPath.c_str () ); if ( FileRename ( strCurPath.c_str (), strNewPath.c_str () ) ) { // If file renamed/moved return success lua_pushboolean ( luaVM, true ); return 1; } else { // Output error m_pScriptDebugging->LogWarning ( luaVM, "%s; unable to rename/move file", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ) ); } } else { // Output error m_pScriptDebugging->LogWarning ( luaVM, "%s failed; source file doesn't exist or destination file already exists", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ) ); } } // Do we have not permissions to both - `current` and `new` resources? else if ( pThisResource != pCurResource && pThisResource != pNewResource ) m_pScriptDebugging->LogError ( luaVM, "%s failed; ModifyOtherObjects in ACL denied resource %s to access %s and %s", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), pThisResource->GetName ().c_str (), pCurResource->GetName ().c_str (), pNewResource->GetName ().c_str () ); // Do we have not permissions to `current` resource? else if ( pThisResource != pCurResource && pThisResource == pNewResource ) m_pScriptDebugging->LogError ( luaVM, "%s failed; ModifyOtherObjects in ACL denied resource %s to access %s", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), pThisResource->GetName ().c_str (), pCurResource->GetName ().c_str () ); // Do we have not permissions to `new` resource? else m_pScriptDebugging->LogError ( luaVM, "%s failed; ModifyOtherObjects in ACL denied resource %s to access %s", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), pThisResource->GetName ().c_str (), pNewResource->GetName ().c_str () ); } } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaXMLDefs::xmlCreateFile ( lua_State* luaVM ) { if ( lua_type ( luaVM, 3 ) == LUA_TLIGHTUSERDATA ) m_pScriptDebugging->LogCustom ( luaVM, "xmlCreateFile may be using an outdated syntax. Please check and update." ); // Grab our resource CLuaMain* pLUA = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLUA ) { CResource* pThisResource = pLUA->GetResource (); CResource* pResource = pThisResource; // Filename if ( ( lua_type ( luaVM, 1 ) != LUA_TSTRING ) || ( lua_type ( luaVM, 2 ) != LUA_TSTRING ) ) { m_pScriptDebugging->LogBadType ( luaVM, "xmlCreateFile" ); lua_pushboolean ( luaVM, false ); return 1; } else { std::string strFile = lua_tostring ( luaVM, 1 ); std::string strPath; if ( CResourceManager::ParseResourcePathInput ( strFile, pResource, &strPath, NULL ) ) { // We have access to modify this resource? if ( pResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { // Make sure the dir exists so we can successfully make the file MakeSureDirExists ( strPath.c_str () ); // Grab the root const char* szRootName = lua_tostring ( luaVM, 2 ); // Create the XML file CXMLFile * xmlFile = pLUA->CreateXML ( strPath.c_str () ); if ( xmlFile ) { // Create its root node CXMLNode* pRootNode = xmlFile->CreateRootNode ( szRootName ); if ( pRootNode ) { lua_pushxmlnode ( luaVM, pRootNode ); return 1; } // Delete it again pLUA->DestroyXML ( xmlFile ); } } } } } lua_pushboolean ( luaVM, false ); return 1; }
// Callback for threaded save // Static function DWORD CScreenShot::ThreadProc ( LPVOID lpdwThreadParam ) { unsigned long ulScreenHeight = ms_uiHeight; unsigned long ulScreenWidth = ms_uiWidth; uint uiReqDataSize = ulScreenHeight * ulScreenWidth * 4; uint uiLinePitch = ulScreenWidth * 4; if ( uiReqDataSize != ms_uiDataSize ) { ms_bIsSaving = false; return 0; } // Create the screen data buffer BYTE** ppScreenData = NULL; ppScreenData = new BYTE* [ ulScreenHeight ]; for ( unsigned short y = 0; y < ulScreenHeight; y++ ) { ppScreenData[y] = new BYTE [ ulScreenWidth * 4 ]; } // Copy the surface data into a row-based buffer for libpng #define BYTESPERPIXEL 4 unsigned long ulLineWidth = ulScreenWidth * 4; for ( unsigned int i = 0; i < ulScreenHeight; i++ ) { memcpy ( ppScreenData[i], (BYTE*) ms_pData + i* uiLinePitch, ulLineWidth ); for ( unsigned int j = 3; j < ulLineWidth; j += BYTESPERPIXEL ) { ppScreenData[i][j] = 0xFF; } } MakeSureDirExists( ms_strFileName ); FILE *file = fopen (ms_strFileName, "wb"); if ( file ) { png_struct* png_ptr = png_create_write_struct ( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL ); png_info* info_ptr = png_create_info_struct ( png_ptr ); png_init_io ( png_ptr, file ); png_set_filter ( png_ptr, 0, PNG_FILTER_NONE ); png_set_compression_level ( png_ptr, 1 ); png_set_IHDR ( png_ptr, info_ptr, ulScreenWidth, ulScreenHeight, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT ); png_set_rows ( png_ptr, info_ptr, ppScreenData ); png_write_png ( png_ptr, info_ptr, PNG_TRANSFORM_BGR | PNG_TRANSFORM_STRIP_ALPHA, NULL ); png_write_end ( png_ptr, info_ptr ); png_destroy_write_struct ( &png_ptr, &info_ptr ); fclose(file); } else { CCore::GetSingleton ().GetConsole ()->Printf ( "Could not create screenshot file '%s'", *ms_strFileName ); } // Clean up the screen data buffer if ( ppScreenData ) { for ( unsigned short y = 0; y < ulScreenHeight; y++ ) { delete [] ppScreenData[y]; } delete [] ppScreenData; } ms_bIsSaving = false; return 0; }
int CLuaFileDefs::fileRename ( lua_State* luaVM ) { // bool fileRename ( string filePath, string newFilePath ) SString strInputSrcPath; SString strInputDestPath; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strInputSrcPath ); argStream.ReadString ( strInputDestPath ); if ( !argStream.HasErrors () ) { // Grab our lua VM CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( !pLuaMain ) { lua_pushboolean ( luaVM, false ); return 1; } #ifdef MTA_CLIENT if ( !g_pNet->ValidateBinaryFileName ( strInputDestPath ) ) { argStream.SetCustomError ( SString ( "Filename not allowed %s", *strInputDestPath ), "File error" ); m_pScriptDebugging->LogError ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; } #endif // absPath: the real absolute path to the file // metaPath: path relative to the target resource (as would be defined in the meta.xml file) SString strSrcAbsPath; SString strDestAbsPath; CResource* pThisResource = pLuaMain->GetResource (); CResource* pSrcResource = pThisResource; CResource* pDestResource = pThisResource; if ( CResourceManager::ParseResourcePathInput ( strInputSrcPath, pSrcResource, &strSrcAbsPath ) && CResourceManager::ParseResourcePathInput ( strInputDestPath, pDestResource, &strDestAbsPath ) ) { CheckCanModifyOtherResource( argStream, pThisResource, pSrcResource, pDestResource ); CheckCanAccessOtherResourceFile( argStream, pThisResource, pSrcResource, strSrcAbsPath ); CheckCanAccessOtherResourceFile( argStream, pThisResource, pDestResource, strDestAbsPath ); if ( !argStream.HasErrors() ) { // Does `current` file path exist and `new` file path doesn't exist? if ( FileExists(strSrcAbsPath) ) { if ( !FileExists ( strDestAbsPath ) ) { #ifdef MTA_CLIENT // Inform file verifier g_pClientGame->GetResourceManager ()->OnFileModifedByScript ( strSrcAbsPath, "fileRename" ); #endif // Make sure the destination folder exists so we can move the file MakeSureDirExists ( strDestAbsPath ); if ( FileRename ( strSrcAbsPath, strDestAbsPath ) ) { // If file renamed/moved return success lua_pushboolean ( luaVM, true ); return 1; } // Output error m_pScriptDebugging->LogWarning ( luaVM, "fileRename failed; unable to rename file" ); } else { m_pScriptDebugging->LogWarning ( luaVM, "fileRename failed; destination file already exists" ); } } else { m_pScriptDebugging->LogWarning ( luaVM, "fileRename failed; source file doesn't exist" ); } } } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaXMLDefs::xmlLoadFile ( lua_State* luaVM ) { if ( lua_type ( luaVM, 2 ) == LUA_TLIGHTUSERDATA ) m_pScriptDebugging->LogCustom ( luaVM, "xmlLoadFile may be using an outdated syntax. Please check and update." ); // Grab our resource CLuaMain* pLUA = m_pLuaManager->GetVirtualMachine ( luaVM ); if ( pLUA ) { SString strFile; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strFile ); if ( !argStream.HasErrors () ) { SString strPath; CResource* pThisResource = pLUA->GetResource (); CResource* pOtherResource = pThisResource; // Resolve other resource from name if ( CResourceManager::ParseResourcePathInput ( strFile, pOtherResource, &strPath, NULL ) ) { // We have access to modify other resource? if ( pOtherResource == pThisResource || m_pACLManager->CanObjectUseRight ( pThisResource->GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE, "ModifyOtherObjects", CAccessControlListRight::RIGHT_TYPE_GENERAL, false ) ) { // Make sure the dir exists so we can successfully make the file MakeSureDirExists ( strPath ); // Create the XML CXMLFile* xmlFile = pLUA->CreateXML ( strPath.c_str () ); if ( xmlFile ) { // Try to parse it if ( xmlFile->Parse () ) { // Grab the root node. If it didn't exist, create one CXMLNode * pRootNode = xmlFile->GetRootNode (); if ( !pRootNode ) pRootNode = xmlFile->CreateRootNode ( "root" ); // Could we create one? if ( pRootNode ) { // Return the root node lua_pushxmlnode ( luaVM, pRootNode ); return 1; } } // Destroy it if we failed pLUA->DestroyXML ( xmlFile ); } } else argStream.SetCustomError( SString( "ModifyOtherObjects in ACL denied resource '%s' to access '%s'", pThisResource->GetName ().c_str (), pOtherResource->GetName ().c_str () ), "Access denied" ); } } if ( argStream.HasErrors () ) m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); } lua_pushboolean ( luaVM, false ); return 1; }
/////////////////////////////////////////////////////////////// // // MkDir // // Returns true if the directory is created or already exists // TODO: Make bTree off option work // /////////////////////////////////////////////////////////////// bool SharedUtil::MkDir ( const SString& strInPath, bool bTree ) { SString strPath = PathConform ( strInPath ); MakeSureDirExists ( strPath + PATH_SEPERATOR ); return DirectoryExists ( strPath ); }