/////////////////////////////////////////////////////////////////////////////////////
// clears documents list
void TPdfFrontend::ClearDocuments(void)
{
	for(int i = 0; i < Documents.GetCount(); i++)
		FileDelete(Documents[i]);		
	DocumentList.Clear();
	Documents.Clear();
	FileDelete(GetPdfDataPath()+"seqf");
	
} // END TPdfFrontend::ClearDocuments()
Beispiel #2
0
static BOOL WriteDIBClip(
/************************************************************************/
LPBITMAPINFOHEADER lpInfo,
LPSTR lpImageFile,
LPSTR lpMaskFile)
{
FNAME szFileName;

if ( lpInfo->biSize != 40 || // make sure it's the correct length
	 lpInfo->biCompression != BI_RGB ) // no compression
	return(FALSE);

if ( lpImageFile )
	{
	if ( !WriteDIB(lpInfo, lpImageFile) )
		return(FALSE);
	}

if ( lpMaskFile )
	{
	if ( !WriteDIBMask(lpInfo, lpMaskFile) )
		{
		lstrcpy(szFileName, lpImageFile);
		FileDelete(szFileName);
		return(FALSE);
		}
	}

return(TRUE);
}
Beispiel #3
0
void GrabScreen::ButSnap_Push() {
/*	program->Minimize();
	
	TopWindow win;
	Button b;
	b.SetLabel("CLOSE");
	b <<= win.Breaker();
	StaticImage desktop;
	desktop.Set(Snap_Desktop());
	win.Add(desktop.SizePos());
	win.Add(b.LeftPos(10, 100).TopPos(10, 30));
	
	win.FullScreen().Run();
	
	program->Overlap();
*/	
	String fileName = ~editFileNameSnap;
	FileDelete(fileName);
	
	String ext = GetFileExt(fileName);
	
	if (ext == ".png") {
		PNGEncoder encoder;
		if (!encoder.SaveFile(fileName, canvasImage))
			Exclamation(Format(t_("Impossible to save %s"), fileName));
	} else if (ext == ".jpg") {	
		JPGEncoder encoder(90);
		if (!encoder.SaveFile(fileName, canvasImage))
			Exclamation(Format(t_("Impossible to save %s"), fileName));
	} else
		Exclamation(Format(t_("File format \"%s\" not found"), ext));
}
Beispiel #4
0
void Updater::DO_Uninstall(void)
{
	// removes executable
	String path;
#ifdef PLATFORM_POSIX
			path = AppendFileName(GetProgramsFolder(), appName);
#else
			path = AppendFileName(GetProgramsFolder(), appName + "/" + appName + ".exe");
#endif
	FileDelete(path);
	
	// removes system config folder
	// leaves user one alone, it can contain user data
	// (on win32, that's also the program folder)
	DeleteFolderDeep(systemConfigPath);
	
	// unlink application from shess
	ShellUnlink();

	// signal op success and leave
	// as it was uninstalling, it will restart
	// launching app (uninstaller, possibily)
	SucceedUpdate();
	RestartApp(RestartTemp);
}
Beispiel #5
0
BOOLEAN GetCDLocation( )
{
	UINT32	uiStrngLength = 0;
	CHAR8		zCdLocation[ SGPFILENAME_LEN ];
	UINT32	uiDriveType=0;
	UINT32	uiRetVal=0;

	//Do a crude check to make sure the Ja2.ini file is the right on

	uiRetVal = GetPrivateProfileString( "Ja2 Settings","CD", "", zCdLocation, SGPFILENAME_LEN, GAME_INI_FILE );
	if( uiRetVal == 0 || !IsDriveLetterACDromDrive( zCdLocation ) )
	{
		// the user most likely doesnt have the file, or the user has messed with the file
		// build a new one
		
		//First delete the old file
		FileDelete( GAME_INI_FILE );

		//Get the location of the cdrom drive
		if( GetCDromDriveLetter( zCdLocation ) )
		{
			CHAR8		*pTemp;

			//if it succeeded
			pTemp = strrchr( zCdLocation, ':' );
			pTemp[0] = '\0';
		}
		else
		{
			//put in a default location
			sprintf( zCdLocation, "c" );
		}

		//Now create a new file
		 WritePrivateProfileString( "Ja2 Settings", "CD", zCdLocation, GAME_INI_FILE );

		 GetPrivateProfileString( "Ja2 Settings","CD", "", zCdLocation, SGPFILENAME_LEN, GAME_INI_FILE );
	}

	uiStrngLength = strlen( zCdLocation );

	//if the string length is less the 1 character, it is a drive letter
	if( uiStrngLength == 1 )
	{
		sprintf( gzCdDirectory, "%s:\\%s", zCdLocation, CD_ROOT_DIR );
	}

	//else it is most likely a network location
	else if( uiStrngLength > 1 )
	{
		sprintf( gzCdDirectory, "%s\\%s", zCdLocation, CD_ROOT_DIR );
	}
	else
	{
		//no path was entered
		gzCdDirectory[ 0 ] = '.';
	}

	return( TRUE );
}
Beispiel #6
0
	bool FileSystem::FolderRemove(const String& path, bool recursive /*= true*/) const
	{
		if (!IsFolderExist(path))
			return false;

		if (!recursive)
			return RemoveDirectoryA(path.Data()) == TRUE;

		WIN32_FIND_DATA f;
		HANDLE h = FindFirstFile((path + "/*").Data(), &f);
		if (h != INVALID_HANDLE_VALUE)
		{
			do
			{
				if (strcmp(f.cFileName, ".") == 0 || strcmp(f.cFileName, "..") == 0)
					continue;

				if (f.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
					FolderRemove(path + "/" + f.cFileName, true);
				else
					FileDelete(path + "/" + f.cFileName);
			} while (FindNextFile(h, &f));
		}

		FindClose(h);

		return RemoveDirectoryA(path.Data()) == TRUE;
	}
Beispiel #7
0
bool FinishSave(String tmpfile, String outfile)
{
	if(IsDeactivationSave()) {
		FileMove(tmpfile, outfile);
		return true;
	}
	Progress progress;
	int time = GetTickCount();
	for(;;) {
		progress.SetTotal(10000);
		progress.SetText("Saving '" + GetFileName(outfile) + "'");
		if(!FileExists(tmpfile))
			return false;
		FileDelete(outfile);
		if(FileMove(tmpfile, outfile))
			return true;
		IdeConsoleFlush();
		Sleep(200);
		if(progress.SetPosCanceled((GetTickCount() - time) % progress.GetTotal())) {
			int art = Prompt(Ctrl::GetAppName(), CtrlImg::exclamation(),
				"Unable to save current file.&"
				"Retry save, ignore it or save file to another location?",
				"Save as...", "Retry", "Ignore");
			if(art < 0)
				return false;
			if(art && AnySourceFs().ExecuteSaveAs())
				outfile = AnySourceFs();
			progress.SetPos(0);
		}
	}
}
Beispiel #8
0
// file_delete(char *filename)
int TrapFileDeleteHandler(uint32 *trapArgs, int sysMode) {
  char filename[FILE_MAX_FILENAME_LENGTH];
  char *user_filename = NULL;
  int i;

  // If we're not in system mode, we need to copy everything from the
  // user-space virtual address to the kernel space address
  if (!sysMode) {
    // Get the arguments themselves into system space
    // Argument 0: userland pointer to filename string
    MemoryCopyUserToSystem (currentPCB, (trapArgs+0), &user_filename, sizeof(uint32));

    // Now copy userland filename string into our filename buffer
    for(i=0; i<FILE_MAX_FILENAME_LENGTH; i++) {
      MemoryCopyUserToSystem(currentPCB, (user_filename+i), &(filename[i]), sizeof(char));
      // Check for end of user-space string
      if (filename[i] == '\0') break;
    }
    if (i == FILE_MAX_FILENAME_LENGTH) {
      printf("TrapFileDeleteHandler: length of filename longer than allowed!\n");
      GracefulExit();
    }
    dbprintf('F', "TrapDeleteCloseHandler: just parsed filename (%s) from trapArgs\n", filename);
 
  } else {
    // Already in kernel space, no address translation necessary
    dstrncpy(filename, (char *)(trapArgs[0]), FILE_MAX_FILENAME_LENGTH);
  }
  return FileDelete(filename);
}
Beispiel #9
0
void Ide::ExportProject(const String& ep, bool all, bool gui, bool deletedir)
{
	SaveFile(false);
	::Workspace wspc;
	wspc.Scan(main);
	Index<String> used;
	HdependClearDependencies();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& p = wspc.GetPackage(i);
		String pn = wspc[i];
		for(int j = 0; j < p.GetCount(); j++) {
			const Package::File& f = p[j];
			if(!f.separator) {
				String p = SourcePath(pn, f);
				used.FindAdd(p);
				Vector<String> d = HdependGetDependencies(p);
				for(int q = 0; q < d.GetCount(); q++)
					used.FindAdd(d[q]);
				for(int q = 0; q < f.depends.GetCount(); q++)
					used.FindAdd(SourcePath(pn, f.depends[q].text));
			}
		}
	}
	if(FileExists(ep)) {
		if(gui && !PromptYesNo(DeQtf(ep) + " is existing file.&"
		                "Do you want to delete it?")) return;
		FileDelete(ep);
	}
	if(deletedir && DirectoryExists(ep)) {
		if(gui && !PromptYesNo(DeQtf(ep) + " is existing directory.&"
		                "Do you want to replace it?")) return;
		DeleteFolderDeep(ep);
	}

	Progress pi("Exporting project");
	pi.SetTotal(wspc.GetCount());
	for(int i = 0; i < wspc.GetCount(); i++) {
		if(gui && pi.StepCanceled())
			return;
		CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true);
	}
	Vector<String> upp = GetUppDirs();
	for(int i = 0; i < upp.GetCount(); i++) {
		if(gui && pi.StepCanceled())
			return;
		String d = upp[i];
		FindFile ff(AppendFileName(d, "*"));
		while(ff) {
			if(ff.IsFile()) {
				String fn = ff.GetName();
				String path = AppendFileName(d, fn);
				if(all || used.Find(path) >= 0)
					CopyFile(AppendFileName(ep, fn), path, true);
			}
			ff.Next();
		}
		CopyFolder(AppendFileName(ep, wspc[i]), PackageDirectory(wspc[i]), used, all, true);
	}
	ExportMakefile(ep);
}
Beispiel #10
0
bool GalleryUtil::MoveDirectory(const QFileInfo src, QFileInfo &dst)
{
    QDir srcDir(src.absoluteFilePath());

    dst = MakeUniqueDirectory(dst);
    if (!dst.exists())
    {
        srcDir.mkdir(dst.absoluteFilePath());
        dst.refresh();
    }

    if (!dst.exists() || !dst.isDir())
        return false;

    bool ok = true;
    QDir dstDir(dst.absoluteFilePath());
    srcDir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
    QFileInfoList list = srcDir.entryInfoList();
    QFileInfoList::const_iterator it = list.begin();
    for (; it != list.end(); ++it)
    {
        const QString fn = it->fileName();
        QFileInfo dfi(dstDir, fn);
        ok &= Move(*it, dfi);
    }

    return ok && FileDelete(src);
}
void DVLib::FileMove(const std::wstring& from, const std::wstring& to)
{
	if (FileExists(to)) 
		FileDelete(to);

	CHECK_WIN32_BOOL(::MoveFileW(from.c_str(), to.c_str()),
		L"Error moving \"" << from << L"\" to \"" << to << L"\"");
}
/////////////////////////////////////////////////////////////////////////////////////
// removes a document from document list
bool TPdfFrontend::RemoveDocument(int index)
{
	if(index < 0 || index >= DocumentList.GetCount())
		return false;
	FileDelete(Documents[index]);
	DocumentList.Remove(index);
	Documents.Remove(index);
	
} // END TPdfFrontend::RemoveDocument()
Beispiel #13
0
void VfkStream::Close()
{
	streams.Clear();
	if(indexfile.IsOpen()) {
		indexfile.Close();
		FileDelete(indexfilename);
	}
	tables.Clear();
	header.Clear();
}
Beispiel #14
0
//////////////////////////////////////////////////////////
//
// HandleResetSettings
//
//
//
//////////////////////////////////////////////////////////
void HandleResetSettings ( void )
{
    if ( CheckAndShowFileOpenFailureMessage () )
        return;

    CheckAndShowMissingFileMessage();

    SString strSaveFilePath = PathJoin ( GetSystemPersonalPath(), "GTA San Andreas User Files" );
    SString strSettingsFilename = PathJoin ( strSaveFilePath, "gta_sa.set" );
    SString strSettingsFilenameBak = PathJoin ( strSaveFilePath, "gta_sa_old.set" );

    if ( FileExists ( strSettingsFilename ) )
    {
        int iResponse = MessageBoxUTF8 ( NULL, _("There seems to be a problem launching MTA:SA.\nResetting GTA settings can sometimes fix this problem.\n\nDo you want to reset GTA settings now?"), "MTA: San Andreas"+_E("CL08"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST );
        if ( iResponse == IDYES )
        {
            FileDelete ( strSettingsFilenameBak );
            FileRename ( strSettingsFilename, strSettingsFilenameBak );
            FileDelete ( strSettingsFilename );
            if ( !FileExists ( strSettingsFilename ) )
            {
                AddReportLog ( 4053, "Deleted gta_sa.set" );
                MessageBoxUTF8 ( NULL, _("GTA settings have been reset.\n\nPress OK to continue."), "MTA: San Andreas", MB_OK | MB_ICONINFORMATION | MB_TOPMOST );
            }
            else
            {
                AddReportLog ( 5054, SString ( "Delete gta_sa.set failed with '%s'", *strSettingsFilename ) );
                MessageBoxUTF8 ( NULL, SString ( _("File could not be deleted: '%s'"), *strSettingsFilename ), "Error"+_E("CL09"), MB_OK | MB_ICONWARNING | MB_TOPMOST );
            }
        }
    }
    else
    {
        // No settings to delete, or can't find them
        int iResponse = MessageBoxUTF8 ( NULL, _("Are you having problems running MTA:SA?.\n\nDo you want to see some online help?"), "MTA: San Andreas", MB_YESNO | MB_ICONQUESTION | MB_TOPMOST );
        if ( iResponse == IDYES )
        {
            BrowseToSolution ( "crashing-before-gtalaunch", TERMINATE_PROCESS );
        }
    }
}
Beispiel #15
0
void GameInitHistory()
{
  if( ( FileExists( HISTORY_DATA_FILE ) ) )
	{
	  // unlink history file
		FileClearAttributes( HISTORY_DATA_FILE );
	  FileDelete( HISTORY_DATA_FILE );
	}

	AddHistoryToPlayersLog(HISTORY_ACCEPTED_ASSIGNMENT_FROM_ENRICO, 0, GetWorldTotalMin( ), -1, -1);
	
}
Beispiel #16
0
bool CWRequest::IsServerRunning(string sSessionID, int iTimeoutMS, string* pErrorMessage)
{
    if(sSessionID == "")
    {
        if(pErrorMessage != NULL) *pErrorMessage = "Session ID is empty.";
        return false;
    }

    // read server pid
    string instance_filename = TempDir() + sSessionID + ".server";
    int fd = -1;
    int file_size = 0;
    if(!FileOpenExistingAndLock(instance_filename, iTimeoutMS, &fd, &file_size, pErrorMessage))
        return false;

    int server_pid = 0;
    if(!FileReadInt(fd, &server_pid, pErrorMessage))
    {
        FileUnlockAndClose(fd, NULL);
        return false;
    }
    FileUnlockAndClose(fd, NULL);

    // check if server is running
    if(!IsProcessRunning(server_pid))
    {
        if(pErrorMessage != NULL) *pErrorMessage = "Server is not running.";

        // if server is not running, delete server pid file and server queue
        FileDelete(instance_filename, NULL);

        string queue_filename = TempDir() + sSessionID + ".queue";
        if(FileExists(queue_filename))
            FileDelete(queue_filename, NULL);

        return false;
    }

    return true;
}
bool CScriptDebugging::SetLogfile ( const char* szFilename, unsigned int uiLevel )
{
    assert ( szFilename );

    // Close the previously loaded file
    if ( m_pLogFile )
    {
        fprintf ( m_pLogFile, "INFO: Logging to this file ended\n" );
        fclose ( m_pLogFile );
        m_pLogFile = NULL;
    }

    // Apply log size limit
    uint uiMaxSizeKB = 0;
    g_pCore->GetCVars ()->Get ( "max_clientscript_log_kb", uiMaxSizeKB );
    if ( uiMaxSizeKB > 0 )
    {
        uint uiCurrentSizeKB = FileSize ( szFilename ) / 1024;
        if ( uiCurrentSizeKB > uiMaxSizeKB )
        {
            SString strFilenameBackup ( "%s.bak", szFilename );
            FileDelete ( strFilenameBackup );
            FileRename ( szFilename, strFilenameBackup );
            FileDelete ( szFilename );
        }
    }

    // Try to load the new file
    FILE* pFile = fopen ( szFilename, "a+" );
    if ( pFile )
    {
        // Set the new pointer and level and return true
        m_uiLogFileLevel = uiLevel;
        m_pLogFile = pFile;
        return true;
    }

    return false;
}
Beispiel #18
0
U8 db_createConfigDb(void)
{
	sFILE *fp = FileOpen(DB_CONFIG_NAME, "war");

	if (fp != NULL) {
		FileDelete(fp);
	}
	FileClose(fp);
	if (DbfCreate(DB_CONFIG_NAME, CONFIG_FIELD_CNT, configFieldName, configFieldSize) < 0)
		return ERROR;

	return NO_ERR;
}
Beispiel #19
0
int CLuaFileDefs::fileDelete ( lua_State* luaVM )
{
    //  bool fileDelete ( string filePath )
    SString strInputPath;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadString ( strInputPath );

    // This is only really necessary server side
    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 )
        {
            SString strAbsPath;
            CResource* pThisResource = pLuaMain->GetResource ();
            CResource* pResource = pThisResource;
            if ( CResourceManager::ParseResourcePathInput ( strInputPath, pResource, &strAbsPath ) )
            {
                CheckCanModifyOtherResource( argStream, pThisResource, pResource );
                CheckCanAccessOtherResourceFile( argStream, pThisResource, pResource, strAbsPath );
                if ( !argStream.HasErrors() )
                {
#ifdef MTA_CLIENT
                    // Inform file verifier
                    g_pClientGame->GetResourceManager ()->OnFileModifedByScript ( strAbsPath, "fileDelete" );
#endif
                    if ( FileDelete ( strAbsPath ) )
                    {
                        // If file removed successfully, return true
                        lua_pushboolean ( luaVM, true );
                        return 1;
                    }
                
                    // Output error "Operation failed @ 'fileDelete' [strInputPath]"
                    argStream.SetCustomError ( strInputPath, "Operation failed" );
                }
            }
        }
    }

    if ( argStream.HasErrors () )
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
//
// Cycle (log) files when they reach a certain size.
//
// uiCycleThreshKB - 0 = never cycle   1 = always cycle   >1 cycle when main file reaches this size
//
void SharedUtil::CycleFile( const SString& strPathFilename, uint uiCycleThreshKB, uint uiNumBackups )
{
    if ( uiCycleThreshKB == 0 )
        return;

    if ( uiCycleThreshKB == 1 || FileSize( strPathFilename ) / 1024 > uiCycleThreshKB )
    {
        for( uint i = 0 ; i < uiNumBackups ; i++ )
        {
            // Rename older files .1 .2 etc
            uint uiNew = uiNumBackups - 1 - i;
            uint uiOld = uiNumBackups - i;
            SString strFilenameNewer = strPathFilename + ( uiNew ? SString( ".%d", uiNew ) : "" );
            SString strFilenameOlder = strPathFilename + ( uiOld ? SString( ".%d", uiOld ) : "" );
    
            FileDelete( strFilenameOlder );
            FileRename( strFilenameNewer, strFilenameOlder );
            FileDelete( strFilenameNewer );
        }

        FileDelete( strPathFilename );            
    }
}
Beispiel #21
0
bool SendMail(string sFrom, string sTo, string sSubject, string sBody, bool bIsHTML, string sSendMailPath, string* pErrorMessage)
{
    string message = "";

    if(sFrom != "") message.append("From: " + sFrom + "\r\n");
    if(sTo != "") message.append("To: " + sTo + "\r\n");
    if(sSubject != "") message.append("Subject: " + sSubject + "\r\n");
    if(bIsHTML)
        message.append("Content-Type: text/html\r\n");
    else
        message.append("Content-Type: text/plain\r\n");

    if(sBody != "") message.append(sBody);

    string temp_file_name = TempDir() + CreateID(sFrom + sTo) + ".tmp";
    if(!FileSaveString(temp_file_name, message, 0, pErrorMessage))
        return false;

	string sendmail_path = "";
	if(sSendMailPath == "")
		sendmail_path = DEFAULT_SENDMAIL_PATH;
	else
		sendmail_path = sSendMailPath;

    string arguments = "";
    arguments.append("-t < ");
    arguments.append("\"" + temp_file_name + "\"");
    if(!Execute(sendmail_path, arguments, true, pErrorMessage))
    {
        FileDelete(temp_file_name, NULL);
        return false;
    }

    FileDelete(temp_file_name, NULL);

    return true;
}
Beispiel #22
0
void SelectPackageDlg::OnBaseRemove()
{
	int c = base.GetCursor();
	if(c < 0)
		return;
	String next;
	if(c + 1 < base.GetCount())
		next = base.Get(c + 1);
	else if(c > 0)
		next = base.Get(c - 1);
	String vars = base.Get(0);
	String varpath = VarFilePath(vars);
	if(PromptOKCancel(NFormat("Remove base file [* \1%s\1]?", varpath)) && !FileDelete(varpath))
		Exclamation(NFormat("Error deleting file [* \1%s\1].", varpath));
	SyncBase(next);
}
Beispiel #23
0
bool GalleryUtil::DeleteDirectory(const QFileInfo &dir)
{
    if (!dir.exists())
        return false;

    QDir srcDir(dir.absoluteFilePath());
    srcDir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
    QFileInfoList list = srcDir.entryInfoList();
    QFileInfoList::const_iterator it = list.begin();
    for (; it != list.end(); ++it)
    {
        const QString fn = it->fileName();
        Delete(*it);
    }

    return FileDelete(dir);
}
Beispiel #24
0
bool DeleteFolderDeep(const char *dir)
{
	{
		FindFile ff(AppendFileName(dir, "*.*"));
		while(ff) {
			String name = ff.GetName();
			String p = AppendFileName(dir, name);
			if(ff.IsFile())
				FileDelete(p);
			else
			if(ff.IsFolder())
				DeleteFolderDeep(p);
			ff.Next();
		}
	}
	return DirectoryDelete(dir);
}
Beispiel #25
0
bool GalleryUtil::Delete(const QFileInfo &file)
{
    if (!file.exists())
        return false;

    if (file.isDir())
        return DeleteDirectory(file);

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("DELETE FROM gallerymetadata "
                  "WHERE image = :IMAGE ;");
    query.bindValue(":IMAGE", file.absoluteFilePath());
    if (query.exec())
        return FileDelete(file);

    return false;
}
Beispiel #26
0
bool GalleryUtil::DeleteDirectory(const QFileInfo &dir)
{
    if (!dir.exists())
        return false;

    QDir srcDir(dir.absoluteFilePath());
    QFileInfoList list = srcDir.entryInfoList();
    QFileInfoList::const_iterator it = list.begin();
    for (; it != list.end(); ++it)
    {
        const QString fn = it->fileName();
        if (fn != "." && fn != "..")
            Delete(*it);
    }

    return FileDelete(dir);
}
Beispiel #27
0
void GrabScreen::ButGrab_Push() {
#if defined(PLATFORM_WIN32) 
	FileDelete(editFileNameGrab.GetData().ToString());
	
	bool ret;
	if (swGrabMode.GetData() == 0) 
		ret = Record_Desktop(~editFileNameGrab, editTime, editFrameRate, opGrabMouse);
	else if (swGrabMode.GetData() == 1) 
		ret = Record_Window(~editFileNameGrab, editTime, GetWindowIdFromCaption(~editWindowTitle, false), editFrameRate, opGrabMouse);
	else if (swGrabMode.GetData() == 2) 
		ret = Record_DesktopRectangle(~editFileNameGrab, editTime, editLeft, editTop, editWidth, editHeight, editFrameRate, opGrabMouse);
	else
		throw Exc("Unexpected value");
	if (!ret)
		Exclamation("Error on grabbing");
#endif
}
Beispiel #28
0
static bool FileMove(const QFileInfo &src, const QFileInfo &dst)
{
    // attempt to rename the file,
    // this will fail if files are on different partitions
    QByteArray source = src.absoluteFilePath().toLocal8Bit();
    QByteArray dest   = dst.absoluteFilePath().toLocal8Bit();
    if (rename(source.constData(), dest.constData()) == 0)
    {
        return true;
    }

    // src and dst are on different mount points, move manually.
    if (errno == EXDEV)
    {
        if (FileCopy(src, dst))
            return FileDelete(src);
    }

    return false;
}
Beispiel #29
0
int CLuaFileDefs::fileDelete ( lua_State* luaVM )
{
//  bool fileDelete ( string filePath )
    SString filePath;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadString ( filePath );

    if ( !argStream.HasErrors () )
    {
        // Grab our lua VM
        CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
        if ( pLuaMain )
        {
            std::string strPath;
            CResource* pResource = pLuaMain->GetResource ();
            if ( CResourceManager::ParseResourcePathInput ( filePath, pResource, strPath ) )
            {
                // Inform file verifier
                g_pClientGame->GetResourceManager()->FileModifedByScript( strPath );

                if ( FileDelete ( strPath.c_str () ) )
                {
                    // If file removed return success
                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
                else
                {
                    // Output error
                    argStream.SetCustomError( SString( "unable to delete file '%s'", *filePath ) );
                }
            }
        }
    }
    if ( argStream.HasErrors () )
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Beispiel #30
0
int fileDelete(char *name)
{
#ifdef USE_FILE_API
    Err     error       = errNone;
    
    error = FileDelete(0, name);
#else
    UInt32  volIterator = vfsIteratorStart;
    UInt16  volRefNum   = 0;
    Err     error       = errNone;
    
    error = VFSVolumeEnumerate(&volRefNum, &volIterator);
    if (error) {
            return -1;
    }
    
    error = VFSFileDelete(volRefNum, name);
#endif

    return 0;
}