Beispiel #1
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 #2
0
bool GalleryUtil::Move(const QFileInfo &src, QFileInfo &dst)
{
    if (src.isDir())
        return MoveDirectory(src, dst);

    dst = MakeUnique(dst);

    if (!FileMove(src, dst))
        return false;

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("UPDATE gallerymetadata "
                  "SET image = :IMAGENEW "
                  "WHERE image = :IMAGEOLD");
    query.bindValue(":IMAGENEW", dst.absoluteFilePath());
    query.bindValue(":IMAGEOLD", src.absoluteFilePath());
    if (query.exec())
        return true;

    // try to undo move on DB failure
    FileMove(dst, src);
    return false;
}
Beispiel #3
0
bool RenamePackageFs(const String& upp, const String& newname)
{
	if(IsNull(newname)) {
		Exclamation("Wrong name.");
		return false;
	}
	if(FileExists(PackagePath(newname))) {
		Exclamation("Package [* \1" + newname + "\1] already exists!");
		return false;
	}
	String pf = GetFileFolder(upp);
	String npf = GetPackagePathNest(pf) + "/" + newname;
	RealizePath(npf);
	if(!FileMove(pf, npf)) {
		Exclamation("Renaming package folder has failed.");
		return false;
	}
	if(!FileMove(npf + "/" + GetFileName(upp), npf + "/" + GetFileName(newname) + ".upp")) {
		FileMove(npf, pf);
		Exclamation("Renaming .upp file has failed.");
		return false;
	}
	return true;
}
Beispiel #4
0
BOOL CALLBACK Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg) {
	case WM_INITDIALOG: {
		Rect wr;
		SystemParametersInfo(SPI_GETWORKAREA, 0, wr, 0);
		Rect dr;
		GetWindowRect(hwnd, dr);
		Point p = wr.CenterPos(dr.Size());
		SetWindowPos(hwnd, 0, p.x, p.y, dr.Width(), dr.Height(),
		             SWP_SHOWWINDOW|SWP_NOOWNERZORDER|SWP_NOZORDER);
		SetWindowText(GetDlgItem(hwnd, 101), "C:\\upp");
		SendDlgItemMessage(hwnd, 101, EM_SETSEL, (WPARAM) 0, (LPARAM) -1);
		SetWindowText(hwnd, GetExeTitle());
 		break;
	}
	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDOK: {
			char h[2048];
			GetWindowText(GetDlgItem(hwnd, 101), h, 2048);
			String exe = AppendFileName(h, "theide.exe");
			if(FileExists(exe)) {
				MessageBox(::GetActiveWindow(),
				           "Please uninstall previous version before installing the new one.",
			               "Ultimate++", MB_ICONSTOP | MB_OK | MB_APPLMODAL);
				WinExec(exe + " -uninstall", SW_SHOWNORMAL);
				break;
			}

			ProgressMeter pi;
			pi.SetText("Installing files");
			HRSRC hrsrc = FindResource(NULL, LPCTSTR(1112), RT_RCDATA);
			if(!hrsrc) Error();
			outdir = h;
			LZMAExtract((const char *)LockResource(LoadResource(NULL, hrsrc)), SizeofResource(NULL, hrsrc),
			            h, pi);
			if (BST_CHECKED == SendDlgItemMessage(hwnd, 10 /*IDC_ASSOC*/, BM_GETCHECK, 0, 0)) {
				SetWinRegString(exe, "", "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\theide.exe\\");
				SetWinRegString(h, "Path", "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\theide.exe\\");
				SetWinRegString("TheIDE.upp", "", ".upp\\", HKEY_CLASSES_ROOT);
				SetWinRegString("open", "", "TheIDE.upp\\shell\\", HKEY_CLASSES_ROOT);
				SetWinRegString("\"" + exe + "\" \"%1\"", "", "TheIDE.upp\\shell\\open\\command\\", HKEY_CLASSES_ROOT);
			}
			pi.Destroy();
			FileMove(AppendFileName(h, IsWow64() ? "theide64.exe" : "theide32.exe"), exe);
			EndDialog(hwnd, 0);
			WinExec(exe, SW_SHOWNORMAL);
			break;
		}
		case 999: {
		    BOOL retVal;
			char Folder[256] = "C:\\";
			char FolderName[17] = "Select Directory";
			if(BrowseFolder( 0, Folder, FolderName)) {
				strcat(Folder, "\\upp");
				SetWindowText(GetDlgItem(hwnd, 101), Folder);
			}
			break;
		}
		case IDCANCEL:
			EndDialog(hwnd, 0);
			break;
		}
	}
	return 0;
}
Beispiel #5
0
	//I/maWriteLog(20616): @@@ URL: mosync://PhoneGap?service=File&action=moveTo&args={"fullPath":"/mnt/sdcard/hello2.txt","pa
	//rent":{"isFile":false,"isDirectory":true,"name":"sdcard","fullPath":"/mnt/sdcard","filesystem":null},"newName":"hello3.t
	//xt"}&PhoneGapCallBackId=File19
	void PhoneGapFile::actionCopyMoveHelper(JSONMessage& message, bool move)
	{
		String callbackID = message.getParam("PhoneGapCallBackId");

		String sourcePath = message.getArgsField("fullPath");

		String destinationName = message.getArgsField("newName");

		// Get the destination path from the JSON tree.
		String destinationPath;
		bool success = message.getJSONParamParentFullPath(destinationPath);
		if (!success)
		{
			callFileError(callbackID, FILEERROR_NO_MODIFICATION_ALLOWED_ERR);
			return;
		}

		// Check that we have the required path names.
		if ((sourcePath.size() == 0) ||
			(destinationName.size() == 0) ||
			(destinationPath.size() == 0))
		{
			callFileError(callbackID, FILEERROR_NO_MODIFICATION_ALLOWED_ERR);
			return;
		}

		bool isDirectory;

		// Check that sourcePath exists.
		if (FileIsDirectory(sourcePath))
		{
			isDirectory = true;
		}
		else if (FileExistsHelper(sourcePath))
		{
			isDirectory = false;
		}
		else
		{
			callFileError(callbackID, FILEERROR_NO_MODIFICATION_ALLOWED_ERR);
			return;
		}

		// Compose the full destination path.
		String fullDestinationPath = destinationPath + "/" + destinationName;

		int result;

		if (move)
		{
			result = FileMove(sourcePath, fullDestinationPath);
		}
		else
		{
			result = FileCopy(sourcePath, fullDestinationPath);
		}

		if (result < 0)
		{
			callFileError(callbackID, FILEERROR_NOT_FOUND_ERR);
			return;
		}

		// Send back entry data.
		String entry;
		if (isDirectory)
		{
			entry = emitDirectoryEntry(
				destinationName,
				fullDestinationPath);
		}
		else
		{
			entry = emitFileEntry(
				destinationName,
				fullDestinationPath);
		}
		callSuccess(
			callbackID,
			entry,
			"window.localFileSystem._castEntry");
	}
Beispiel #6
0
bool APIENTRY Load(bool Update_Updater, int nFunsterStil,HINSTANCE thisinstance)
{
	ConfigOpen();
	
	HANDLE PMutex = NULL;
	
	if(OpenMutex(MUTEX_ALL_ACCESS, false, "BackPi4")!=NULL)
	{
		if(doMutex)
		{
			MessageBox(NULL,"Background Pi 4 is already running.","ERROR: LOADER.DLL",MB_OK);
			return true;
		}
	}
	else
	{
		PMutex = CreateMutex(NULL, FALSE, "BackPi4");
	}
	
	HINSTANCE hLib=NULL;
	if(Update_Updater==true)
	{
        hLib=LoadLibrary("UPDATER.dll");
		if(hLib==NULL)
		{
			MessageBox(NULL,"Failed To Load \"UPDATER.DLL\"","ERROR: LOADER.DLL",MB_OK);
			return true;
		}
		Updater=(winUpdater)GetProcAddress((HMODULE)hLib,"Update");
		if(Updater==NULL)
		{
			FreeLibrary(hLib);
			MessageBox(NULL,"Failed To Bind \"UPDATER.DLL\"","ERROR: LOADER.DLL",MB_OK);
			return true;
		}
		Updater(nFunsterStil,hLib);
		FreeLibrary(hLib);
		Updater=NULL;
		ReleaseMutex(PMutex);
    	CloseHandle(PMutex);
		return false;
    }
    else
    {
		
		//What CPU we running?
		
		//ConfigOpen();
		
		//Put the GMP DLL into place
		
		if(!FileMove("libgmp_" + Arch + ".dll","libgmp-3.dll"))
		{
			MessageBox(NULL,"Failed To Prepare GMP Library\nFailed to use CPU Type: " + Arch,"ERROR: LOADER.DLL",MB_OK);
			return true;
		}
		
		//Done.		
		
        hLib=LoadLibrary("MAIN.dll");

		if(hLib==NULL)
		{
			MessageBox(NULL,"Failed To Load \"MAIN.DLL\"","ERROR: LOADER.DLL",MB_OK);
			return true;
		}
		
		Main=(winMainf)GetProcAddress((HMODULE)hLib,"Main");
		if(Main==NULL)
		{
			FreeLibrary(hLib);
			MessageBox(NULL,"Failed To Bind \"MAIN.DLL\"","ERROR: LOADER.DLL",MB_OK);
			return true;
		}
		bool Temp = true;
		
		Temp=Main(nFunsterStil,hLib);
		FreeLibrary(hLib);
		Main=NULL;
		if(!Temp) 
		{
			ReleaseMutex(PMutex);
    		CloseHandle(PMutex);
		}
		return Temp;
    }
    MessageBox(NULL,"Oh Shit.","Loader.DLL",MB_OK);
    return true;
}