Exemple #1
0
wxString GdaCache::GetFullPath()
{
    wxString exePath = wxStandardPaths::Get().GetExecutablePath();
    wxFileName exeFile(exePath);
    wxString exeDir = exeFile.GetPathWithSep();
    return exeDir + "cache.sqlite";
}
wxString get_exe_path()
{
   	wxStandardPathsBase& stdp = wxStandardPaths::Get();
    wxFileName exeFile(stdp.GetExecutablePath()); 
    wxString strExePath = exeFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
	return  strExePath;
}
Exemple #3
0
void CInstall::ExtractUpdaterCopy()
{
	// Declare variables
	HRSRC resource;
	HGLOBAL resourceData;
	long * lpResLock;
	DWORD dwResourceSize;
	CString sUpdaterLocation, sResourceName, sUpdaterCopyLocation;

	// Get updater location
	sUpdaterLocation.Format(m_pPath->GetPathUpdaterExecutable());

	// Find the right resource
	sResourceName.Format(_T("#%d"), MAKEINTRESOURCE(IDR_UPDATERCOPY));
	resource = FindResource(NULL, sResourceName, _T("Bin"));

	// Load the executable resource
	resourceData = LoadResource(NULL, resource);

	// Get start address of resource
	lpResLock = (long *) LockResource(resourceData);

	// Get size of resource
	dwResourceSize = SizeofResource(NULL, resource);

	try
	{
		// Set up filename
		sUpdaterCopyLocation.Format(_T("%s\\%s"), m_pPath->GetPathTemp(), _T("UpdaterCopy.exe"));

		// Create file
		CFile exeFile(sUpdaterCopyLocation, CFile::modeWrite | CFile::modeCreate);

		// Wait until class is created
		Sleep(100);

		// Write data to executable
		exeFile.Write(lpResLock, dwResourceSize);

		// Close executable
		exeFile.Close();
	}

	// If there were any errors, catch them
	catch (CException * pEx)
	{
#if defined _DEBUG || defined _BETA
		pEx->ReportError();
#endif
		// Delete exception object to prevent leaks
		pEx->Delete();
	}
}
/**
 * Confirm that an executable file exists at location.
 */
void TskExecutableModule::setPath(const std::string& location)
{
    try
    {
        // Autogenerate filename extension if needed
        Poco::Path tempPath = location;
        if (tempPath.getExtension().empty())
        {
            std::string os = Poco::Environment::osName();
            if (os.find("Windows") != std::string::npos ||
                os.find("CYGWIN")  != std::string::npos ||
                os.find("MINGW")   != std::string::npos )
            {
                tempPath.setExtension("exe");
            }
            // Else we assume the user is on a platform that doesn't use executable extensions.
        }

        // Call our parent to validate the location.
        TskModule::setPath(tempPath.toString());

        m_name = Poco::Path(m_modulePath).getBaseName();

        // Verify that the file is executable.
        Poco::File exeFile(m_modulePath);

        if (!exeFile.canExecute())
        {
            std::wstringstream msg;
            msg << L"TskExecutableModule::setPath - File is not executable: "
                << m_modulePath.c_str();
            LOGERROR(msg.str());
            throw TskException("File is not executable.");
        }
    }
    catch (TskException& tskEx)
    {
        throw tskEx;
    }
    catch(std::exception& ex)
    {
        // Log a message and throw a framework exception.
        std::wstringstream msg;
        msg << "TskExecutableModule::setPath : " << ex.what();
        LOGERROR(msg.str());

        throw TskException("Failed to set location: " + m_modulePath);
    }
}
/** Uncompile model: remove compiled version.
  * Returns true if it has been successful or if there were no compiled version.
  */
bool ModPlusOMCtrl::uncompile()
{
    // info
    InfoSender::instance()->sendNormal("Removing compiled model : "+name());

    // first remove initfile
    QFileInfo initFile(_ModelPlus->mmoFolder(),_initFileXml);
    LowTools::removeFile(initFile.absoluteFilePath());

    // remove exeFile
    QFileInfo exeFile(_ModelPlus->mmoFolder(),_exeFile);
    if(!exeFile.exists())
        return true;

    return LowTools::removeFile(exeFile.absoluteFilePath());
}
Exemple #6
0
static bool QHYSDKInit()
{
    if (s_qhySdkInitDone)
        return false;

    uint32_t ret;

    if ((ret = InitQHYCCDResource()) != 0)
    {
        Debug.Write(wxString::Format("InitQHYCCDResource failed: %d\n", (int)ret));
        return true;
    }

#if defined (__APPLE__)
    wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath());
    wxString exePath(exeFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));

    const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(exePath);
    const char *temp = (const char *)tmp_buf;
    size_t const len = strlen(temp) + 1;
    char *destImgPath = new char[len];
    memcpy(destImgPath, temp, len);

    if ((ret = OSXInitQHYCCDFirmware(destImgPath)) != 0)
    {
        Debug.Write(wxString::Format("OSXInitQHYCCDFirmware(%s) failed: %d\n", destImgPath, (int)ret));
        delete[] destImgPath;
        return true;
    }
    delete[] destImgPath;

    // lzr from QHY says that it is important to wait 5s for firmware download to complete
    WorkerThread::MilliSleep(5000);
#endif

    s_qhySdkInitDone = true;
    return false;
}
VError XWinFolder::RetainSystemFolder( ESystemFolderKind inFolderKind, bool inCreateFolder, VFolder **outFolder )
{
	VString folderPath;
	UniChar path[4096];
	size_t maxLength = sizeof( path)/sizeof( UniChar);
	path[maxLength-2]=0;
	VFolder* sysFolder = NULL;
	DWORD winErr = ERROR_PATH_NOT_FOUND;
	switch( inFolderKind)
	{
		case eFK_Executable:
			{
				DWORD pathLength = ::GetModuleFileNameW( NULL, path, (DWORD) maxLength);
				if (testAssert( pathLength != 0 && !path[maxLength-2])) 
				{
					folderPath.FromUniCString( path );
					VFile exeFile( folderPath );
					sysFolder = exeFile.RetainParentFolder();
					winErr = 0;
				}
				break;
			}

		case eFK_Temporary:
			{
				DWORD length = ::GetTempPathW( (DWORD) maxLength, path);
				if ( (length > 0) && (length <= maxLength) && !path[maxLength-2])
				{
					DWORD size = ::GetLongPathNameW( path, NULL, 0);
					if (size > 0)
					{
						UniChar *p = folderPath.GetCPointerForWrite( size-1);
						if (p != NULL)
						{
							DWORD result = ::GetLongPathNameW( path, p, size);
							if (result == 0)
								winErr = GetLastError();
							else
								winErr = 0;
							folderPath.Validate( result);
							sysFolder = new VFolder( folderPath );
						}
					}
				}
				break;
			}

		default:
			{
				int type;
				switch( inFolderKind)
				{
					case eFK_UserDocuments:			type = CSIDL_PERSONAL; break;
					case eFK_CommonPreferences:		type = CSIDL_COMMON_APPDATA; break;
					case eFK_UserPreferences:		type = CSIDL_APPDATA; break;
					case eFK_CommonApplicationData:	type = CSIDL_COMMON_APPDATA; break;
					case eFK_UserApplicationData:	type = CSIDL_APPDATA; break;
					case eFK_CommonCache:			type = CSIDL_COMMON_APPDATA; break;
					case eFK_UserCache:				type = CSIDL_LOCAL_APPDATA; break;
					default: xbox_assert( false);	type = CSIDL_APPDATA; break;
				}
				HRESULT result = ::SHGetFolderPathW( NULL, type, NULL, SHGFP_TYPE_CURRENT, path);
				if ( result == S_OK || result == S_FALSE )	// S_FALSE means The CSIDL is valid, but the folder does not exist.
				{
					folderPath.FromUniCString( path);
					if (folderPath[folderPath.GetLength()-1] != FOLDER_SEPARATOR)
						folderPath += FOLDER_SEPARATOR;
					sysFolder = new VFolder( folderPath );
					winErr = 0;
				}
				break;
			}
	}

	if ( (sysFolder != NULL) && !sysFolder->Exists() )
	{
		if (inCreateFolder)
		{
			if (sysFolder->CreateRecursive() != VE_OK)
				ReleaseRefCountable( &sysFolder);
		}
		else
		{
			ReleaseRefCountable( &sysFolder);
		}
	}

	*outFolder = sysFolder;
	return MAKE_NATIVE_VERROR( winErr);
}
Exemple #8
0
MaraUpdaterApplication::MaraUpdaterApplication(int &argc, char **argv) : QApplication(argc, argv),
		_window(new MaraUpdaterWindow())
{
	//MaraTrace trace(__FUNCSIG__, this, __FILE__, __LINE__);

	_app = this;
	qInstallMsgHandler(qtMessageHandler);

	_executeCancelled = false;

	_autoRestart = false;
	_launchedFromTemp = false;

	QStringList args = arguments();

	for(QStringList::iterator ii = args.begin(); ii != args.end(); ++ii)
	{
		if((*ii).toLower() == "autorestart")
		{
			_autoRestart = true;
		}

		if((*ii) == "__TEMP_LAUNCHED__")
		{
			_launchedFromTemp = true;
		}
	}

	if(_launchedFromTemp)
	{
		//MaraTrace trace(__FUNCSIG__ ":TempLaunched", this, __FILE__, __LINE__);
		executeUpdate();
	}
	else
	{
		//MaraTrace trace(__FUNCSIG__ ":NotTempLaunched", this, __FILE__, __LINE__);
		QFileInfo exeFileInfo(QCoreApplication::applicationFilePath());
		QString tempPath = QDir::temp().filePath(exeFileInfo.fileName());
		QFile temp(tempPath);

		if(temp.exists() && !temp.remove())
		{
			QMessageBox::warning(0, "Error", QString("Error removing temp executable %1:\n%2\n\nUpdater will not be able to update itself.").arg(tempPath).arg(temp.errorString()));
			executeUpdate();
		}

		QFile exeFile(QCoreApplication::applicationFilePath());

		std::cout << "Copying self to " << qPrintable(tempPath) << "..." << std::flush;

		if(exeFile.copy(tempPath))
		{
			std::cout << "Success!" << std::flush;
			if(!QProcess::startDetached(tempPath, args << "__TEMP_LAUNCHED__"))
			{
				QMessageBox::critical(0, "Error", QString("Failed launching temp updater."));
			}
			_executeCancelled = true;
		}
		else
		{
			QMessageBox::warning(0, "Error", QString("Error copying to temp location %1:\n%2\n\nUpdater will not be able to update itself.").arg(tempPath).arg(exeFile.errorString()));
			executeUpdate();
		}
	}
}