Esempio n. 1
0
void getResourceDirPath(boost::filesystem::path& path)
{

#if defined(SQUIDGE_PLATFORM_MACOSX)
   // Executable location is at 'Squidge.app/Contents/MacOS/Squidge'
   // Resource directory is at 'Squidge.app/Contents/Resources'

   getExecutablePath(path);
   path = path.parent_path().parent_path();
   path /= "Resources";
   path = canonical(path);

#elif defined(SQUIDGE_PLATFORM_WINDOWS)
   // Executable location is at '.../Squidge.exe'
   // Resource directory is at '.../Resources'

   getExecutablePath(path);
   path = path.parent_path();
   path /= "Resources";
   path = canonical(path);

#else

   #error No impl of getResourceDirPath on this platform!

#endif

}
Esempio n. 2
0
void FlexOptionManager::InitOptions(
    struct sGuiOptions *pGuiOptions,
    struct sOptions *pOptions,
    int argc,
    char *const argv[])
{
    pOptions->drive[0]         = "system.dsk";
    pOptions->drive[1]         = "";
    pOptions->drive[2]         = "";
    pOptions->drive[3]         = "";
    pOptions->mdcrDrives[0]    = "system.mdcr";
    pOptions->mdcrDrives[1]    = "";
    pOptions->hex_file         = "neumon54.hex";
    pOptions->startup_command  = "";
    pOptions->term_mode        = false;
    pOptions->isRamExtension   = true;
    pOptions->isHiMem          = false;
    pOptions->isFlexibleMmu    = false;
    pOptions->isEurocom2V5     = false;
    pOptions->use_undocumented = false;
    pOptions->useRtc           = true;
#ifndef _WIN32
#ifndef HAVE_X11
    pOptions->term_mode        = true;
#endif
#endif
    pOptions->reset_key        = 0x1e; // is Ctrl-^ for reset or Sig. INT
    pOptions->frequency        = -1.0; // default: ignore

    pGuiOptions->argc          = argc;
    pGuiOptions->argv          = argv;
    pGuiOptions->color         = "green";
    pGuiOptions->nColors       = 2;
    pGuiOptions->isInverse     = false;
#ifdef UNIX
    pGuiOptions->doc_dir       = F_DATADIR;
    pGuiOptions->guiType       = GuiType::XTOOLKIT;
    pOptions->disk_dir         = F_DATADIR;
#endif
#ifdef _WIN32
    pGuiOptions->doc_dir       = getExecutablePath() + PATHSEPARATORSTRING + "Documentation";
    pGuiOptions->guiType       = GuiType::WINDOWS;
    pOptions->disk_dir         = getExecutablePath() + PATHSEPARATORSTRING + "Data";
#endif
    pGuiOptions->pixelSizeX      = 2;
    pGuiOptions->pixelSizeY      = 2;
    pGuiOptions->isSynchronized  = false;
} // InitOptions
Esempio n. 3
0
STDMETHODIMP ProcessWrap::COMGETTER(ExecutablePath)(BSTR *aExecutablePath)
{
    LogRelFlow(("{%p} %s: enter aExecutablePath=%p\n", this, "Process::getExecutablePath", aExecutablePath));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aExecutablePath);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = getExecutablePath(BSTROutConverter(aExecutablePath).str());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave *aExecutablePath=%ls hrc=%Rhrc\n", this, "Process::getExecutablePath", *aExecutablePath, hrc));
    return hrc;
}
Esempio n. 4
0
bool Config::loadConfigFile()
{
	std::string dirPath;
#ifndef _DEBUG
	dirPath = getExecutablePath();
#else
	dirPath = getCurrentDirectory();
#endif
	
	// if we have an env variable set for this, use that...
	const char* smPathEnv = getenv("SITEMON_PATH");
	if (smPathEnv && strlen(smPathEnv) > 0)
	{
		dirPath.assign(smPathEnv);
	}
	
	if (dirPath.substr(dirPath.size() - 1, 1) != "/")
	{
		dirPath += "/";
	}
	
	std::string finalPath = dirPath;
	
	// try XML config file first...
	if (loadXMLConfigFile(finalPath + "sm_config.xml"))
	{
		return true;
	}
	
	return false;
}
Esempio n. 5
0
int env(int argc, char **argv) {
  char epath[PATH_MAX + 1];
  char *oldpath = getenv("PATH");

  assert(oldpath);

  if (!getExecutablePath(epath, sizeof(epath)))
    exit(EXIT_FAILURE);

  if (argc <= 1) {
    const std::string &pname = getParentProcessName();

    if (pname == "csh" || pname == "tcsh") {
      std::cerr << std::endl << "you are invoking this program from a C shell, "
                << std::endl << "please use " << std::endl << std::endl
                << "setenv PATH `" << epath << "/osxcross-env -v=PATH`"
                << std::endl << std::endl << "instead." << std::endl
                << std::endl;
    }
  }

  std::vector<std::string> path;
  std::map<std::string, std::string> vars;

  splitPath(oldpath, path);

  if (!hasPath(path, epath))
    path.push_back(epath);

  vars["PATH"] = joinPath(path);

  auto printVariable = [&](const std::string & var)->bool {
    auto it = vars.find(var);
    if (it == vars.end()) {
      std::cerr << "unknown variable '" << var << "'" << std::endl;
      return false;
    }
    std::cout << it->second << std::endl;
    return true;
  };

  if (argc <= 1) {
    std::cout << std::endl;
    for (auto &v : vars) {
      std::cout << "export " << v.first << "=";
      if (!printVariable(v.first))
        return 1;
      std::cout << std::endl;
    }
  } else {
    if (strncmp(argv[1], "-v=", 3))
      return 1;

    const char *var = argv[1] + 3;
    return static_cast<int>(printVariable(var));
  }

  return 0;
}
void CrashHandlerPOSIX::fillBasicCrashInfo() {
	CrashHandlerImpl::fillBasicCrashInfo();
	std::string exe = getExecutablePath();
	if(exe.length() < ARRAY_SIZE(m_pCrashInfo->execFullName)) {
		strcpy(m_pCrashInfo->execFullName, exe.c_str());
	} else {
		m_pCrashInfo->execFullName[0] = '\0';
	}
}
Esempio n. 7
0
std::string getFlexemuSystemConfigFile()
{
    static const auto flexemuConfigFile = std::string("flexemu.conf");

#ifdef _WIN32
    return getExecutablePath() + PATHSEPARATORSTRING + flexemuConfigFile;
#endif
#ifdef __LINUX
    return std::string(F_SYSCONFDIR) + PATHSEPARATORSTRING + flexemuConfigFile;
#endif
}
Esempio n. 8
0
boost::filesystem::path Helper::Paths::getAppDataDir() const
{
  boost::filesystem::path ret;
  if(_executablePath.empty())
    _executablePath = getExecutablePath();
  if(_homedir.empty())
    _homedir = getHomeDir();

  ret = _homedir;
  ret += _executablePath.stem();
  return ret;
}
Esempio n. 9
0
File: gcc.c Progetto: alexbiehl/ghc
int main(int argc, char** argv) {
    char *binDir;
    char *exePath;
    char *preArgv[4];
    char *oldPath;
    char *newPath;
    char *base;
    char *version;
    int n;

    binDir = getExecutablePath();
    exePath = mkString("%s/realgcc.exe", binDir);

    /* We need programs like
           inplace/mingw/libexec/gcc/mingw32/4.5.0/cc1.exe
       to be able to find the DLLs in inplace/mingw/bin, so we need to
       add it to $PATH */
    oldPath = getenv("PATH");
    if (!oldPath) {
        die("Couldn't read PATH\n");
    }
    n = snprintf(NULL, 0, "PATH=%s;%s", binDir, oldPath);
    n++;
    newPath = malloc(n);
    if (!newPath) {
        die("Couldn't allocate space for PATH\n");
    }
    snprintf(newPath, n, "PATH=%s;%s", binDir, oldPath);
    n = putenv(newPath);
    if (n) {
        die("putenv failed\n");
    }

    /* GCC Version. */
    version = mkString("%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);

    /* Without these -B args, gcc will still work. However, if you
       have a mingw installation in c:/mingw then it will use files
       from that in preference to the in-tree files. */
    preArgv[0] = mkString("-B%s", binDir);
    preArgv[1] = mkString("-B%s/../lib", binDir);
#ifdef __MINGW64__
    base = mkString("x86_64-w64-mingw32");
#else
    base = mkString("i686-w64-mingw32");
#endif

    preArgv[2] = mkString("-B%s/../lib/gcc/%s/%s"    , binDir, base, version);
    preArgv[3] = mkString("-B%s/../libexec/gcc/%s/%s", binDir, base, version);

    run(exePath, 4, preArgv, argc - 1, argv + 1);
}
Esempio n. 10
0
bool fixWorkingDirectory() {
   std::string executablePath;
   if (!getExecutablePath(executablePath)) {
      return false;
   }

   std::string executableDir;
   if (!getDirectoryFromPath(executablePath, executableDir)) {
      return false;
   }

   return setWorkingDirectory(executableDir);
}
Esempio n. 11
0
void CrashHandlerImpl::fillBasicCrashInfo() {
	m_pCrashInfo->architecture = ARX_ARCH;
	m_pCrashInfo->processId = getProcessId();

	strcpy(m_pCrashInfo->crashReportFolder, "crashes");

	strncpy(m_pCrashInfo->executablePath, getExecutablePath().c_str(), sizeof(m_pCrashInfo->executablePath));
	m_pCrashInfo->executablePath[sizeof(m_pCrashInfo->executablePath)-1] = 0; // Make sure our string is null terminated

	strncpy(m_pCrashInfo->executableVersion, version.c_str(), sizeof(m_pCrashInfo->executableVersion));
	m_pCrashInfo->executableVersion[sizeof(m_pCrashInfo->executableVersion)-1] = 0; // Make sure our string is null terminated
	
}
Esempio n. 12
0
int main(int argc, char *argv[]) {
	// DEBUG_MSG("Hello world!");

  std::string path = getExecutablePath();
  // DEBUG_MSG("Executable path: "<<path)

  lua_State* state = luaL_newstate();
  DEBUG_MSG("Lua state opened.")

  // Assign panic function:
  // lua_atpanic (_state, panic_handler);

  DEBUG_MSG("Opening base libraries...");
  luaL_openlibs(state);

  // Set the root path:
  lua_pushstring(state, path.c_str());
  lua_setglobal(state, "root_path");

  // Execute the entry point:
  std::string mainfile = path + "\\run_app.lua";
  DEBUG_MSG("Executing entry point: "<<mainfile);

  // Load the main file:
  if (luaL_loadfile(state, mainfile.c_str()) != 0)
  {
    DEBUG_MSG("[ERROR] During loading of file " << mainfile << ":\n" << lua_tostring(state, -1));
    return 1;
  }

  // push the arguments:
  for(int i = 1; i<argc; ++i)
  {
  	lua_pushstring(state, argv[i]);
  }

  // Now call the script (argc-1 arguments, 1 result)
  /* do the call  */
  if (lua_pcall(state, argc-1, 0, 0) != 0) {
  	 DEBUG_MSG("[ERROR] running app: " << lua_tostring(state, -1));
  	 return 1;
  }       

  DEBUG_MSG("Closing lua state");
	lua_close(state);

  DEBUG_MSG("Execution done.");

	return 0;
};
Esempio n. 13
0
CompilerInstance *createCompilerInstance(int argc, const char **argv)
{
    std::string path = getExecutablePath(argv[0]);
    IntrusiveRefCntPtr<DiagnosticOptions> diag_options = new DiagnosticOptions;
    TextDiagnosticPrinter *diag_client = new TextDiagnosticPrinter(llvm::errs(), &*diag_options);
    IntrusiveRefCntPtr<DiagnosticIDs> diag_id = new DiagnosticIDs;
    DiagnosticsEngine diagnostics(diag_id, &*diag_options, diag_client);

    Driver driver{path, llvm::sys::getDefaultTargetTriple(), diagnostics};
    driver.setTitle("Meditation");

    llvm::SmallVector<const char*, 256> args;
    llvm::SpecificBumpPtrAllocator<char> argAllocator;
    std::error_code EC = llvm::sys::Process::GetArgumentVector(args, llvm::makeArrayRef(argv, argc), argAllocator);
    args.push_back("-fsyntax-only");
    if(EC){
        llvm::errs()<<"Cannot get arguments: " << EC.message() << '\n';
    }

    unique_ptr<Compilation> compilation(driver.BuildCompilation(args));
    if(compilation->getJobs().size()!=1 || !llvm::isa<Command>(*(compilation->getJobs().begin()))) {
        llvm::SmallString<256> msg;
        llvm::raw_svector_ostream out(msg);
        compilation->getJobs().Print(out, "; ", true);
        diagnostics.Report(clang::diag::err_fe_expected_compiler_job) << out.str();
        return nullptr;
    }
    const Command& command = llvm::cast<Command>(*(compilation->getJobs().begin()));
    if (StringRef(command.getCreator().getName()) != "clang") {
        diagnostics.Report(clang::diag::err_fe_expected_clang_command);
        return nullptr;
    }
    const clang::driver::ArgStringList &cc_arguments = command.getArguments();
    unique_ptr<CompilerInvocation> invocation(new CompilerInvocation);
    CompilerInvocation::CreateFromArgs(*invocation, cc_arguments.data(), cc_arguments.data()+cc_arguments.size(), diagnostics);
    invocation->getFrontendOpts().DisableFree = false;

    CompilerInstance *compiler = new CompilerInstance;
    compiler->setInvocation(invocation.release());

    compiler->createDiagnostics();
    if(!compiler->hasDiagnostics()) return nullptr;
    if(compiler->getHeaderSearchOpts().UseBuiltinIncludes && compiler->getHeaderSearchOpts().ResourceDir.empty()){
        compiler->getHeaderSearchOpts().ResourceDir = CompilerInvocation::GetResourcesPath(argv[0], (void*)(intptr_t)getExecutablePath);
    }

    return compiler;

}
Esempio n. 14
0
API OpenGLLodMap *createOpenGLLodMap(OpenGLLodMapDataSource *source, double baseRange, unsigned int viewingDistance)
{
	unsigned int tileSize = getLodMapImageSize(source, OPENGL_LODMAP_IMAGE_HEIGHT);

	OpenGLLodMap *lodmap = ALLOCATE_OBJECT(OpenGLLodMap);
	lodmap->source = source;
	lodmap->heightmap = createOpenGLPrimitiveHeightmap(NULL, tileSize, tileSize); // create a managed heightmap that will serve as instance for our rendered tiles
	lodmap->quadtree = createQuadtree(&createLodMapTile, &freeLodMapTile);
	lodmap->selection = NULL;
	lodmap->viewerPosition = createVector3(0.0, 0.0, 0.0);
	lodmap->baseRange = baseRange;
	lodmap->viewingDistance = viewingDistance;
	lodmap->polygonMode = GL_FILL;
	lodmap->morphStartFactor = 0.8f;
	lodmap->loadingPool = g_thread_pool_new(&loadLodMapTile, lodmap, -1, false, NULL);

	// create lodmap material
	deleteOpenGLMaterial("lodmap");
	char *execpath = getExecutablePath();
	GString *vertexShaderPath = g_string_new(execpath);
	g_string_append_printf(vertexShaderPath, "/modules/lodmap/lodmap.glslv");
	GString *fragmentShaderPath = g_string_new(execpath);
	g_string_append_printf(fragmentShaderPath, "/modules/lodmap/lodmap.glslf");

	bool result = createOpenGLMaterialFromFiles("lodmap", vertexShaderPath->str, fragmentShaderPath->str);

	g_string_free(vertexShaderPath, true);
	g_string_free(fragmentShaderPath, true);
	free(execpath);

	if(!result) {
		freeOpenGLPrimitiveHeightmap(lodmap->heightmap);
		freeQuadtree(lodmap->quadtree);
		logError("Failed to create OpenGL LOD map material");
		return NULL;
	}

	// add lodmap configuration uniforms
	OpenGLUniformAttachment *uniforms = getOpenGLMaterialUniforms("lodmap");
	attachOpenGLUniform(uniforms, "baseRange", createOpenGLUniformFloatPointer(&lodmap->baseRange));
	attachOpenGLUniform(uniforms, "morphStartFactor", createOpenGLUniformFloatPointer(&lodmap->morphStartFactor));
	attachOpenGLUniform(uniforms, "viewerPosition", createOpenGLUniformVector(lodmap->viewerPosition));

	g_hash_table_insert(maps, lodmap->quadtree, lodmap);

	return lodmap;
}
Esempio n. 15
0
void ConfigRoot::osConfigRoot()
{
	// Attempt to locate the Firebird.framework bundle
	root_dir = getFrameworkFromBundle();
	if (root_dir.hasData())
	{
		return;
	}

	root_dir = getExecutablePath();
	if (root_dir.hasData())
	{
		return;
	}

	// As a last resort get it from the default install directory
	root_dir = FB_PREFIX;
}
Esempio n. 16
0
static bool findCustomICUData(std::string& result) {
#if (__APPLE__)
    std::string exePath = getExecutablePath();
    std::string basePath = dirname((char*) exePath.c_str());
#else
    // TODO: Implement custom ICU data lookup on Linux.
    std::string basePath = "/usr/share/icu";
#endif
    std::string icuDataPath = basePath;
    icuDataPath += "/";
    icuDataPath += U_ICUDATA_NAME;
    icuDataPath += ".dat";
    if (!access(icuDataPath.c_str(), R_OK)) {
        result = icuDataPath;
        return true;
    }
    return false;
}
Esempio n. 17
0
static String findWebKitProcess(const char* processName)
{
    static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
    if (execDirectory) {
        String processPath = pathByAppendingComponent(filenameToString(execDirectory), processName);
        if (fileExists(processPath))
            return processPath;
    }

    static String executablePath = getExecutablePath();
    if (!executablePath.isNull()) {
        String processPath = pathByAppendingComponent(executablePath, processName);
        if (fileExists(processPath))
            return processPath;
    }

    // FIXME: Define and use LIBEXECDIR.
    return String(processName);
}
static String findWebKitProcess(const char* processName)
{
#if ENABLE(DEVELOPER_MODE)
static const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
if (execDirectory) {
    String processPath = pathByAppendingComponent(filenameToString(execDirectory), processName);
    if (fileExists(processPath))
        return processPath;
}

static String executablePath = getExecutablePath();
if (!executablePath.isNull()) {
    String processPath = pathByAppendingComponent(executablePath, processName);
    if (fileExists(processPath))
        return processPath;
}
#endif

return pathByAppendingComponent(filenameToString(PKGLIBEXECDIR), processName);
}
Esempio n. 19
0
/**
 * Attaches to the target process.
 *
 * @param tids The thread IDs of the threads that belong to the target process.
 *
 * @return A NaviError code that describes whether the operation was successful or not.
 */
NaviError LinuxSystem::attachToProcess() {


  msglog->log(LOG_VERBOSE, "Trying to attach to process %d", getPID());

  int result = ptrace(PTRACE_ATTACH, getPID(), 0, 0);

  if (result) {
    msglog->log(LOG_ALWAYS, "Error: Couldn't attach to process");
    return errno;
  }

  // TODO: Right now multi-threading is not supported
  Thread ts(getPID(), SUSPENDED);
  tids.push_back(ts);
  setActiveThread (getPID());

std  ::string path;
  NaviError pathError = getExecutablePath(getPID(), path);
  if (pathError) {
    msglog->log(
        LOG_ALWAYS,
        "Error: Unable to determine the executable path of the debuggee.");
    return pathError;
  }

  // Generate processStart message and send it to BinNavi.
  fillModules(getPID(), this->modules);
  std::map<std::string, Module>::const_iterator cit = this->modules.find(path);
  if (cit != this->modules.end()) {
    Module processModule = cit->second;
    processStart(processModule, ts);
  } else {
    msglog->log(LOG_ALWAYS,
                "Error: Unable to determine main process module for '%s'",
                path.c_str());
    exit(0);
  }

  return NaviErrors::SUCCESS;
}
Esempio n. 20
0
void WinWindow::doRunOnStart()
{
    std::string runPath = "\"" + getExecutablePath() + "\" -m";

    Helper::request_privileges(SE_TAKE_OWNERSHIP_NAME);

    HKEY hKey;
    LONG result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_WRITE, &hKey);
    if (result == ERROR_SUCCESS)
    {
        if ((result = RegSetValueExA( hKey, "NOSA-Server", 0, REG_SZ, (BYTE*)runPath.c_str(), runPath.length())) == ERROR_SUCCESS)
            MessageBox(NULL, "Now NOSA-Server service will launch of computer start.", "Done!", MB_ICONINFORMATION | MB_OK);
        else
            MessageBox(NULL, "You don't have sufficient rights to edit your registry. Please try run this application with admin privilege.", "Error!",  MB_ICONERROR | MB_OK);
    }
    else
        MessageBox(NULL, "Your registry has wrong format!", "Error!", MB_ICONERROR | MB_OK);

    RegCloseKey(hKey);
    return;
}
Esempio n. 21
0
void WinWindow::doRun(bool asService)
{
    if (processCount(serverExecutable) > 0)
    {
        MessageBox(NULL, "Server executable is already running. ", "Error!",  MB_ICONERROR | MB_OK);
        return;
    }

    std::string runPath = getExecutablePath();
    if (runPath != "")
    {
        std::string parameter;
        if (asService)
            parameter = "-m";

        if (startProgram(runPath, parameter))
        {
            if (asService)
                MessageBox(NULL, "Server successfully started.", "Success",  MB_ICONINFORMATION | MB_OK);
        }
    }
}
Esempio n. 22
0
bool CrashHandlerImpl::initialize() {
	Autolock autoLock(&m_Lock);
	
	bool initialized = true;
	
	fs::path local_path = fs::path(getExecutablePath());
	if(!local_path.empty()) {
		local_path = local_path.parent() / m_CrashHandlerApp;
		if(fs::exists(local_path)) {
			m_CrashHandlerPath = local_path;
		}
	}
	if(m_CrashHandlerPath.empty()) {
		local_path = m_CrashHandlerApp;
		if(fs::exists(local_path)) {
			m_CrashHandlerPath = local_path;
		}
	}
	if(fs::libexec_dir && m_CrashHandlerPath.empty()) {
		local_path = fs::path(fs::libexec_dir) / m_CrashHandlerApp;
		if(fs::exists(local_path)) {
			m_CrashHandlerPath = local_path;
		}
	}
	
	if(!createSharedMemory()) {
		return false;
	}
	
	fillBasicCrashInfo();
	
	if(!registerCrashHandlers()) {
		destroySharedMemory();
		initialized = false;
	}

	return initialized;
}
Esempio n. 23
0
bool Config::loadConfigFile(const std::string &configFilePath)
{
	std::string finalPath;

	if (!configFilePath.empty())
	{
		finalPath = configFilePath;
	}
	else
	{
#ifndef _DEBUG
		finalPath = getExecutablePath();
#else
		finalPath = getCurrentDirectory();
#endif

		finalPath += "sm_config.xml";
	}

//	finalPath = "/Users/peter/sm_config.xml";

	TiXmlDocument doc(finalPath);

	if (!doc.LoadFile())
	{
		return false;
	}

	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem = NULL;

	pElem = hDoc.FirstChildElement("config").Element();

	if (!pElem)
		return false;

	for (TiXmlElement *pItem = pElem->FirstChildElement(); pItem; pItem = pItem->NextSiblingElement())
	{
		const std::string &elementName = pItem->ValueStr();

		std::string content;
		if (pItem->GetText())
			content = pItem->GetText();

		if (elementName == "web_content_path")
		{
			m_configSettings.m_webContentPath = content;
		}
		else if (elementName == "mon_db_path")
		{
			m_configSettings.m_monitoringDBPath = content;
		}
		else if (elementName == "loadtest_db_path")
		{
			m_configSettings.m_loadTestingDBPath = content;
		}
		else if (elementName == "web_server_port")
		{
			if (!content.empty())
			{
				int port = atoi(content.c_str());
				m_configSettings.m_webServerPort = port;
			}
		}
		else if (elementName == "proxy")
		{
			loadProxySettings(pItem);
		}
	}

	return true;
}
Esempio n. 24
0
HINSTANCE launch_program(const std::wstring& program) {
	HINSTANCE result = ShellExecute(NULL, NULL, getExecutablePath(program).c_str(), NULL, NULL, NULL);
	return result;
}
Esempio n. 25
0
int main(int argc, char ** argv)
{
  setExecutablePath(argv[0]);

  lua_State *L = lua_open();

  luaL_openlibs(L);

#if USE_IUP
  iuplua_open(L);
  cdlua_open(L);
  cdluaiup_open(L);

  iupkey_open(L);
  iupimlua_open(L);
  IupImageLibOpen ();
  iupcontrolslua_open(L);
  imlua_open(L);
  imlua_open_process(L);
#endif

  luaopen_pack(L);
  luaopen_lfs(L);
  luaopen_marshal(L);
  luaopen_mime_core(L);
  luaopen_socket_core(L);

  pdfdoc_register(L);
  pdfpage_register(L);
  clipboard_register(L);
  luaopen_system(L);
  luaopen_compare(L);

#if _DEBUG 
  lua_pushboolean(L, true);
  lua_setfield(L, LUA_GLOBALSINDEX, "_DEBUG");
#endif
  
  char luaFile[512] = "";
  char playlistFile[512] = "";
  int beginIndex = 1;
  if (argc > 1)
  {
    int strl = strlen(argv[1]);
    bool isLuaFile = strcmp(&argv[1][strl-4], ".lua") == 0;
    if (isLuaFile)
    {
      beginIndex = 2;
      strcpy_s(luaFile, sizeof(luaFile), argv[1]);
    }
    else if (strcmp(&argv[1][strl-5], ".sing") == 0
      || strcmp(&argv[1][strl-4], ".m3u") == 0
      || strcmp(&argv[1][strl-4], ".txt") == 0)
    {
    }
  }
  if (!luaFile[0])
  {
    lua_pushboolean(L, true);
    lua_setfield(L, LUA_GLOBALSINDEX, "APPLOADED");
	const char* execPath = getExecutablePath();
	sprintf_s(luaFile, sizeof(luaFile), "%s\\%s", execPath, "main.lua");
  }
    
  int temp_int = luaL_loadfile(L,luaFile);
  
  int returnval = 0;
  if (temp_int)
  {
    const char *error = lua_tostring(L, -1);
    printf("Error in file: \"%s\"\n", luaFile);
    printf("%s\n", error);
    returnval = 1;
  }
  else
  {
    const char *error;

    for (int i = beginIndex; i < argc; i++)
      lua_pushstring(L, argv[i]);

    if (docall(L,argc-beginIndex,0))
    {
      error = lua_tostring(L, -1);
      if (error)
        std::cout << error;
      returnval = 1;
    }
  }
  close(L);

  return returnval;
}
Esempio n. 26
0
/* RunDialog::getSelectedCommandLine
 * Returns a command line based on the currently selected run
 * configuration and resources
 *******************************************************************/
string RunDialog::getSelectedCommandLine(Archive* archive, string map_name, string map_file)
{
	Executables::game_exe_t* exe = Executables::getGameExe(choice_game_exes->GetSelection());
	if (exe)
	{
		// Get exe path
		const string exe_path = getExecutablePath(exe);

		if (exe_path.IsEmpty())
			return "";

		string path = S_FMT("\"%s\"", exe_path);

		unsigned cfg = choice_config->GetSelection();
		if (cfg < exe->configs.size())
		{
			path += " ";
			path += exe->configs[cfg].value;
		}

		// IWAD
		Archive* bra = theArchiveManager->baseResourceArchive();
		path.Replace("%i", S_FMT("\"%s\"", bra ? bra->getFilename() : ""));

		// Resources
		path.Replace("%r", getSelectedResourceList());

		// Archive (+ temp map if specified)
		if (map_file.IsEmpty() && archive)
			path.Replace("%a", S_FMT("\"%s\"", archive->getFilename()));
		else
		{
			if (archive)
				path.Replace("%a", S_FMT("\"%s\" \"%s\"", archive->getFilename(), map_file));
			else
				path.Replace("%a", S_FMT("\"%s\"", map_file));
		}

		// Running an archive yields no map name, so don't try to warp
		if (map_name.IsEmpty())
		{
			path.Replace("-warp ", wxEmptyString);
			path.Replace("+map ",  wxEmptyString);
			path.Replace("%mn",    wxEmptyString);
			path.Replace("%mw",    wxEmptyString);
		}
		// Map name
		else
		{
			path.Replace("%mn", map_name);

			// Map warp
			if (path.Contains("%mw"))
			{
				string mn = map_name.Lower();

				// MAPxx
				string mapnum;
				if (mn.StartsWith("map", &mapnum))
					path.Replace("%mw", mapnum);

				// ExMx
				else if (map_name.length() == 4 && mn[0] == 'e' && mn[2] == 'm')
					path.Replace("%mw", S_FMT("%c %c", mn[1], mn[3]));
			}
		}

		// Extra parameters
		if (!text_extra_params->GetValue().IsEmpty())
		{
			path += " ";
			path += text_extra_params->GetValue();
		}

		LOG_MESSAGE(2, "Run command: %s", path);
		return path;
	}

	return "";
}
Esempio n. 27
0
void gt::Platform::associate(bool magnet, bool torrent)
{
    makeDir(getHomeDir() + ".local", 0755);
    makeDir(getHomeDir() + ".local/share", 0755);
    makeDir(getHomeDir() + ".local/share/applications", 0755);


    bool dirtyT = false, dirtyM = false;

    std::ifstream file;
    if(torrent)
    {
        file.open(getHomeDir() + ".local/share/applications/gtorrentt.desktop");
        if(file.is_open())
        {
            string tmp;
            for(int i = 0; i < 6; ++i) getline(file, tmp);
            dirtyT = (tmp != string("Exec=") + getExecutablePath() + " %F\n");
        }
        else
            dirtyT = true;
        file.close();
    }

    if(magnet)
    {
        file.open(getHomeDir() + ".local/share/applications/gtorrentm.desktop");

        if(file.is_open())
        {
            string tmp;
            for(int i = 0; i < 6; ++i) getline(file, tmp);
            dirtyM = (tmp != string("Exec=") + getExecutablePath() + " %u\n");
        }
        else
            dirtyM = true;
        file.close();
    }

    std::ofstream TassFile(getHomeDir() + ".local/share/applications/gtorrentt.desktop");
    std::ofstream MassFile(getHomeDir() + ".local/share/applications/gtorrentm.desktop");

    string TassString =
        string("[Desktop Entry]\n")                          +
        "Version=1.0\n"                                      +
        "Encoding=UTF-8\n"                                   +
        "Name=gTorrent\n"                                    +
        "GenericName=BitTorrent Client\n"                    +
        "Comment=Share files over BitTorrent\n"              +
        "Exec=" + getExecutablePath() + " %F\n"              +
        "Icon=gtorrent.png\n"                                +
        "Terminal=false\n"                                   +
        "Type=Application\n"                                 +
        "MimeType=application/x-bittorrent;\n"               +
        "Categories=Internet;Network;FileTransfer;P2P;GTK;\n";

    string MassString =
        string("[Desktop Entry]\n")                          +
        "Version=1.0\n"                                      +
        "Encoding=UTF-8\n"                                   +
        "Name=gTorrent\n"                                    +
        "GenericName=BitTorrent Client\n"                    +
        "Comment=Share files over BitTorrent\n"              +
        "Exec=" + getExecutablePath() + " %u\n"              +
        "Icon=gtorrent.png\n"                                +
        "Terminal=false\n"                                   +
        "Type=Application\n"                                 +
        "MimeType=x-scheme-handler/magnet;\n;"               +
        "Categories=Internet;Network;FileTransfer;P2P;GTK;\n";

    if(dirtyT)
        TassFile << TassString;
    if(dirtyM)
        MassFile << MassString;

    TassFile.close();
    MassFile.close();

    if(torrent) system("xdg-mime default gtorrentt.desktop application/x-bittorrent");
    if(magnet)  system("xdg-mime default gtorrentm.desktop x-scheme-handler/magnet");
}
Esempio n. 28
0
boost::filesystem::path Helper::Paths::getApplicationDir() const
{
  if(_executablePath.empty())
    _executablePath = getExecutablePath();
  return _executablePath.parent_path();
}
Esempio n. 29
0
const std::string& Utils::getExecutableDirectory()
{
    static const std::string path = FileSystem::getParentDirectory(getExecutablePath());
    return path;
}