コード例 #1
0
void AddType(wxString type)
{
    wxString value;
    wxString madedit_type = wxString(wxT("MadEdit")) + type;

    wxRegKey *pRegKey = new wxRegKey(wxString(wxT("HKEY_CLASSES_ROOT\\")) + type);
    if(!pRegKey->Exists()) pRegKey->Create();
    else pRegKey->QueryValue(wxEmptyString, value);
    if(value != madedit_type)
    {
        if(!value.IsEmpty()) //save old default value
        {
            pRegKey->SetValue(wxT("Old_Default"), value);

            //if(type == wxT(".txt"))
            //{
            //    wxRegKey *pRegKey1 = new wxRegKey(wxString(wxT("HKEY_CLASSES_ROOT\\")) + type);
            //    pRegKey->QueryValue(wxEmptyString, txt_name);
            //    delete pRegKey1;
            //}
        }

        value = madedit_type;
        pRegKey->SetValue(wxEmptyString, value);
    }
    delete pRegKey;

    wxString name(wxT("HKEY_CLASSES_ROOT\\"));
    name += value;

    if(type == wxT(".txt"))
    {
        wxString txt_name;
        pRegKey = new wxRegKey(wxString(wxT("HKEY_CLASSES_ROOT\\txtfile")));
        if(pRegKey->Exists()) pRegKey->QueryValue(wxEmptyString, txt_name);
        delete pRegKey;

        if(txt_name.IsEmpty()) txt_name = wxT("Text file");

        pRegKey = new wxRegKey(name);
        pRegKey->Create();
        pRegKey->SetValue(wxEmptyString, txt_name);
        delete pRegKey;
    }

    name += wxT("\\shell\\open\\command");
    pRegKey = new wxRegKey(name);
    pRegKey->Create();
    wxString exepath=GetExecutablePath();
    pRegKey->SetValue(wxEmptyString, wxString(wxT('"'))+exepath+wxString(wxT("\" \"%1\"")));
    delete pRegKey;

    name = wxT("HKEY_CLASSES_ROOT\\");
    name += value;
    name += wxT("\\DefaultIcon");
    pRegKey = new wxRegKey(name);
    pRegKey->Create();
    pRegKey->SetValue(wxEmptyString, exepath + wxString(wxT(",1")));
    delete pRegKey;
}
コード例 #2
0
bool DetectType(wxString type)
{
	wxLogNull nolog; // disable error log
	wxString value;
	wxRegKey *pRegKey = new wxRegKey( g_MadEditRegkeyPath + type );

	if( pRegKey->Exists() ) { pRegKey->QueryValue( wxEmptyString, value ); }

	delete pRegKey;

	if( !value.IsEmpty() )
	{
		pRegKey = new wxRegKey( g_MadEditRegkeyPath
								+ value
								+ wxString( wxT( "\\shell\\open\\command" ) ) );
		value.Empty();

		if( pRegKey->Exists() ) { pRegKey->QueryValue( wxEmptyString, value ); }

		delete pRegKey;
		wxString exepath = GetExecutablePath();

		if( value.Upper().Find( exepath.Upper() ) >= 0 )
		{
			return true;
		}
	}

	return false;
}
コード例 #3
0
ファイル: utils.cpp プロジェクト: hltj/wxMEdit
void AppPath::Init(const wxString& appname)
{
	cfg_file = appname + wxT(".cfg");

	wxFileName filename(GetExecutablePath());
	filename.MakeAbsolute();
	app_dir = filename.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);

	usr_dir = wxStandardPaths::Get().GetUserDataDir() + wxFILE_SEP_PATH;

#ifdef __WXMSW__
	app_dir_writable = FileWritable(app_dir + wxT("portable_test"));
	cfg_in_usrhome = ConfigWillBeInUserHome();
	if (!cfg_in_usrhome)
	{
		home_dir = app_dir;
		another_dir = usr_dir;
		return;
	}
#endif

	if (cfg_in_usrhome)
		CreateConfigDirInUserHome();

	home_dir = usr_dir;
	another_dir = app_dir;
}
コード例 #4
0
ファイル: common.cpp プロジェクト: lenny93/TouchEnabler
void CommonAPI::Init(HookWrapper* h)
{
	hook = h;
	exePath = GetExecutablePath();

	// Init logging
	FILE* logFile = fopen("touchenabler.log", "w");
	Output2FILE::Stream() = logFile;

	// Init AS
	InitAS();

	// Init Vjoy
	//InitVjoy();

	// Init Input
	InitInput();

	//InitTouch();
	
	if (!SetWindowSubclass(hook->windowHandle,  &WindowProcSubclass, 0, 0))
    {
		FILE_LOG(logERROR) << "Unable to subclass HWND.";
    }


	CallScriptFunction("void OnLoad()");

}
コード例 #5
0
void GetExecutableDir(wchar_t* outdir, int outdir_length)
{
    // Without slash at end.

    // This path is longer than MAX_PATH, do not use it with
    // windows api functions as you might get buffer overflows.

    wchar_t longpath[1024];
    GetExecutablePath(longpath, _countof(longpath));

    wchar_t drive[3];
    wchar_t dir[768];
    wchar_t fname[256];
    wchar_t ext[32];

    errno_t result = _wsplitpath_s(longpath, drive, _countof(drive), dir, _countof(dir), fname, _countof(fname), ext, _countof(ext));
    ASSERT_EXIT((result == 0), "_wsplitpath_s(longpath)");

    swprintf_s(outdir, outdir_length, L"%s%s", drive, dir);

    // remove slash at end
    int len = wcslen(outdir);
    if (outdir[len-1] == '\\' || outdir[len-1] == '/') {
        outdir[len-1] = 0;
    }
}
コード例 #6
0
ファイル: Interpreter.cpp プロジェクト: aurelie-flandi/root
  void Interpreter::AddRuntimeIncludePaths(const char* argv0) {
    // Add configuration paths to interpreter's include files.
#ifdef CLING_INCLUDE_PATHS
    llvm::StringRef InclPaths(CLING_INCLUDE_PATHS);
    for (std::pair<llvm::StringRef, llvm::StringRef> Split
           = InclPaths.split(':');
         !Split.second.empty(); Split = InclPaths.split(':')) {
      if (llvm::sys::fs::is_directory(Split.first))
        AddIncludePath(Split.first);
      InclPaths = Split.second;
    }
    // Add remaining part
    AddIncludePath(InclPaths);
#endif
    llvm::SmallString<512> P(GetExecutablePath(argv0));
    if (!P.empty()) {
      // Remove /cling from foo/bin/clang
      llvm::StringRef ExeIncl = llvm::sys::path::parent_path(P);
      // Remove /bin   from foo/bin
      ExeIncl = llvm::sys::path::parent_path(ExeIncl);
      P.resize(ExeIncl.size());
      // Get foo/include
      llvm::sys::path::append(P, "include");
      if (llvm::sys::fs::is_directory(P.str()))
        AddIncludePath(P.str());
    }

  }
コード例 #7
0
ファイル: Init.cpp プロジェクト: cnndabbler/cn24
void System::Init(int requested_log_level) {
  if(requested_log_level == -1) {
#ifdef BUILD_VERBOSE
    log_level = 3;
#else
    log_level = 2;
#endif
  } else
    log_level = requested_log_level;
  
  LOGINFO << "CN24 version " STRING_SHA1;
  LOGINFO << "Copyright (C) 2015 Clemens-Alexander Brust";
  LOGINFO << "For licensing information, see the LICENSE"
          << " file included with this project.";
          
  std::string binary_path;
  GetExecutablePath(binary_path);
  LOGDEBUG << "Executable path: " << binary_path;
  
  unsigned int platform_number = 0;
  unsigned int device_number = 0;
  
  // Look for configuration file
  std::string config_path = binary_path + "config";
  if(!std::ifstream(config_path, std::ios::in).good()) {
    config_path = binary_path + "../config";
  }
  
  // Load and parse config file
  std::ifstream config_file(config_path, std::ios::in);
  if(config_file.good()) {
    LOGINFO << "Loading config file: " << config_path;
    
    while (!config_file.eof()) {
      std::string line;
      std::getline (config_file, line);
      
      ParseUIntIfPossible(line, "opencl_platform", platform_number);
      ParseUIntIfPossible(line, "opencl_device", device_number);
    }
  } else {
#ifdef BUILD_OPENCL
    LOGINFO << "Could not find a config file, using default OpenCL settings.";
#endif
  }

  CLHelper::Init(platform_number, device_number);
#ifdef BUILD_GUI
  if(!gtk_init_check ( nullptr, nullptr )) {
    LOGWARN << "Could not initialize GTK!";
  }
#endif

  // Initialize global TensorViewer
  viewer = new TensorViewer();
  
  // Initialize global StatAggregator
  stat_aggregator = new StatAggregator();
}
コード例 #8
0
void GetExecutablePathQuoted(wchar_t* outpath, int outpath_length)
{
    wchar_t* temppath = new wchar_t[outpath_length];
    GetExecutablePath(temppath, outpath_length);
    int result = swprintf_s(outpath, outpath_length, L"\"%s\"", temppath);
    ASSERT_EXIT((-1 != result), "swprintf_s(outpath)");
    delete[] temppath;
    temppath = 0;
}
コード例 #9
0
ファイル: rboot.cpp プロジェクト: skopp/rush
void RBoot::AddCommonMediaPath()
{
    char path[_MAX_PATH];
    GetExecutablePath( path, _MAX_PATH );
    Path mediaPath( path );
    mediaPath.SetFileExt( "" );
    mediaPath.DirUp();
    mediaPath.DirAppend( "media" );
    if (mediaPath.Exists())
    {
        g_pFileServer->AddMediaPath( mediaPath.GetFullPath() );
    }
}
コード例 #10
0
ファイル: rboot.cpp プロジェクト: skopp/rush
void RBoot::AddModuleMediaPath()
{
    //  set current working directory to the same where we are located
    char path[_MAX_PATH];
    GetExecutablePath( path, _MAX_PATH );
    Path mediaPath( path );
    mediaPath.SetFileExt( "" );
    mediaPath.DirAppend( "media" );
    if (mediaPath.Exists())
    {
        g_pFileServer->AddMediaPath( mediaPath.GetFullPath() );
    }
}
コード例 #11
0
ファイル: stdpaths.cpp プロジェクト: beanhome/dev
void wxStandardPaths::DetectPrefix()
{
    // we can try to infer the prefix from the location of the executable
    wxString exeStr = GetExecutablePath();
    if ( !exeStr.empty() )
    {
        // consider that we're in the last "bin" subdirectory of our prefix
        size_t pos = exeStr.rfind(wxT("/bin/"));
        if ( pos != wxString::npos )
            m_prefix.assign(exeStr, 0, pos);
    }

    if ( m_prefix.empty() )
    {
        m_prefix = wxT("/usr/local");
    }
}
コード例 #12
0
void GetExecutableName(wchar_t* outdir, int outdir_length)
{
    // Filename without extension.

    wchar_t longpath[1024];
    GetExecutablePath(longpath, _countof(longpath));

    wchar_t drive[3];
    wchar_t dir[768];
    wchar_t fname[256];
    wchar_t ext[32];

    errno_t result = _wsplitpath_s(longpath, drive, _countof(drive), dir, _countof(dir), fname, _countof(fname), ext, _countof(ext));
    ASSERT_EXIT((result == 0), "_wsplitpath_s(longpath)");

    swprintf_s(outdir, outdir_length, L"%s", fname);
}
コード例 #13
0
ファイル: HostMachine.cpp プロジェクト: TomHarte/ElectrEm
char *HostMachine::ResolveFileName(const char *istr)
{
	if(!istr) return NULL;

	char *RetBuf = new char[MaxPathLength()], *RBPtr;
	RBPtr = RetBuf;

	const char *start, *end;
	char * TempStr = new char[MaxPathLength()];
	int CopyOffset;
	start = istr;
	do
	{
		end = start;
		while(*end != '/' && *end) end++;

		memcpy(TempStr, start, end-start);
		TempStr[end-start] = '\0';
		bool Handled = false;
		CopyOffset = 0;

		if(!strcmp(TempStr, "%ROMPATH%") && ROMPath)
		{
			Handled = true;
			memcpy(RBPtr, ROMPath, strlen(ROMPath)+1);
			RBPtr += strlen(ROMPath);
		}

		if(!strcmp(TempStr, "%GFXPATH%") && GFXPath)
		{
			Handled = true;
			memcpy(RBPtr, GFXPath, strlen(GFXPath)+1);
			RBPtr += strlen(GFXPath);
		}

		if(	!strcmp(TempStr, "%EXECPATH%")	|| 
			(!strcmp(TempStr, "%ROMPATH%") && !ROMPath) ||
			(!strcmp(TempStr, "%GFXPATH%") && !GFXPath)
			)
		{
			Handled = true;
			char *T = GetExecutablePath();
			memcpy(RBPtr, T, strlen(T)+1);
			RBPtr += strlen(T);
			delete[] T;
		}

		if(	!strcmp(TempStr, "%HOMEPATH%")	)
		{
#ifndef WIN32
			Handled = true;
			char *T = getenv("HOME");
			memcpy(RBPtr, T, strlen(T)+1);
			RBPtr += strlen(RBPtr);
#else
			Handled = true;
			char *T = getenv("APPDATA");
			if(T)
			{
				memcpy(RBPtr, T, strlen(T)+1);
				RBPtr += strlen(RBPtr);
			}
			else
			{
				T = GetExecutablePath();
				memcpy(RBPtr, T, strlen(T)+1);
				RBPtr += strlen(T);
				delete[] T;
			}
#endif
		}


		if( !strncmp(TempStr, "%DOT%", 5) )
		{
#ifndef WIN32
			RBPtr[0] = '.';
			RBPtr[1] = '\0';
			RBPtr ++;
#endif
			CopyOffset = 5;
		}

		if(!Handled && CopyOffset < (end-start))
		{
			memcpy(RBPtr, &start[CopyOffset], (end-start)-CopyOffset);
			RBPtr += (end-start)-CopyOffset;
		}

		RBPtr[0] = DirectorySeparatorChar();
		RBPtr[1] = '\0';
		RBPtr++;
		start = end+1;
	}
	while(*end);

	delete [] TempStr;

	RBPtr--;
	*RBPtr = '\0';
	return RetBuf;
}
コード例 #14
0
ファイル: Config.cpp プロジェクト: AlexHayton/decoda
wxString GetDedicatedProductCommand()
{
    // Use the EXE in the same directory as Decoda.
    return GetExecutablePath() + wxFileName::GetPathSeparator() + wxT("ns2.exe");
}
コード例 #15
0
	/*
	 * Function to check, validate and then partially apply parameters from internal containers.
	 * It perform data healing and is being executed in two cases:
	 *  - during the initial launch of application
	 *  - when accepting commands from another process
	 * @param iParamIndex - index of the param to be validated
	 * @param bIsFirstLaunch - indicator of the first launch of application
	 */
	void CConfigurationModule::CheckServerParameters(int iParamIndex, bool bIsFirstLaunch)
	{
		try
		{
			IPC::CIPCModule& ipcModule = IPC::CIPCModule::Instance();
			//Let's find out if anything usefull came from the command line
			switch (iParamIndex)
			{
				case eCONFIG_TCP_PORT:
				case eCONFIG_UDP_PORT:
				{
					int iValue = 0;
					int iDefaultValue = 0;
					GetDefaultValue<int>(iParamIndex,iDefaultValue);
					if (!CureParameter<int>(iParamIndex,iValue) || iValue <= 0 || iValue > g_iMaxIPport)
						iValue = iDefaultValue;

					SetSetting<int>(iParamIndex,iValue);
					break;
				}
				case eCONFIG_KILL_PROCESS:
					break;
				case eCONFIG_TCP_IF:
				case eCONFIG_UDP_IF:
				case eCONFIG_DATA_FILE:
				{
					std::string strValue("");
					std::string strDefaultValue("");
					GetDefaultValue<std::string>(iParamIndex,strDefaultValue);
					if (!CureParameter<std::string>(iParamIndex,strValue))
						strValue = strDefaultValue;

					if (!strValue.empty() && (iParamIndex == eCONFIG_DATA_FILE) && (strValue.at(0) != '/'))
					{
						//assume that this is not an absolute path - build relative string
						//based on current directory structure
						std::string strPath = GetExecutablePath();
						bfs::path pathCurrentDirectory = bfs::system_complete(bfs::path(strPath));
						strPath = pathCurrentDirectory.branch_path().string();
						if (strPath.at(strPath.length()-1) != '/')
							strPath += "/";
						strValue = strPath + strValue;
					}

					SetSetting<std::string>(iParamIndex,strValue);
					if (iParamIndex == eCONFIG_DATA_FILE && !bIsFirstLaunch )
					{
						//permit changing data file path only in maintenance mode
						int iMaintenanceMode;
						GetProgramOption(eCONFIG_MAINT,iMaintenanceMode);
						if (iMaintenanceMode)
							ipcModule.SetDataPath(strValue);
					}

					break;
				}
				case eCONFIG_DAEMON_MODE:
				case eCONFIG_MAINT:
				{
					int iValue = 0;
					int iDefaultValue = 0;
					GetDefaultValue<int>(iParamIndex,iDefaultValue);
					if (!CureParameter<int>(iParamIndex,iValue) || iValue > 1 || iValue < 0)
						iValue = iDefaultValue;

					SetSetting<int>(iParamIndex,iValue);

					if (iParamIndex == eCONFIG_MAINT && !bIsFirstLaunch)
					{
						ipcModule.SetMaintenanceMode(iValue);
					}

					break;
				}
				case eCONFIG_SLEEP:
				{
					int iValue = 0;
					int iDefaultValue = 0;
					GetDefaultValue<int>(iParamIndex,iDefaultValue);
					if (!CureParameter<int>(iParamIndex,iValue) || iValue > 9999 || iValue < 0)
						iValue = iDefaultValue;

					SetSetting<int>(iParamIndex,iValue);
					if (!bIsFirstLaunch)
					{
						ipcModule.SetSendTimeout(iValue);
					}
					break;
				}
				case eCONFIG_LOG_LEVEL:
				{
					int iValue = 0;
					int iDefaultValue = 0;
					GetDefaultValue<int>(iParamIndex,iDefaultValue);
					if (!CureParameter<int>(iParamIndex,iValue) || iValue > CErrorLevel::Fatal || iValue < CErrorLevel::Debug)
						iValue = iDefaultValue;

					SetSetting<int>(iParamIndex,iValue);
					LOG_SETLEVEL(static_cast<CErrorLevel::etLogLevel>(iValue));
					break;
				}
				case eCONFIG_THREAD_POOL:
				{
					int iValue = 0;
					int iDefaultValue = 0;
					GetDefaultValue<int>(iParamIndex,iDefaultValue);
					if (!CureParameter<int>(iParamIndex,iValue) || iValue > (int)g_iMaxPoolSize || iValue < (int)g_iMinPoolSize)
						iValue = iDefaultValue;

					SetSetting<int>(iParamIndex,iValue);
					break;
				}
				default:
					LOGERROR << "Unknown parameter id while checking parameters: "<<iParamIndex;
			}
		}
		CATCH
	}
コード例 #16
0
std::string GetExecutableDirectory()
{
    std::string executablePath = GetExecutablePath();
    size_t lastPathSepLoc = executablePath.find_last_of("/");
    return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : "";
}
コード例 #17
0
 const string& Configuration::GetExecutableFullPath() {
     if (mFullPathPtr == NULL) {
         mFullPathPtr = &(GetExecutablePath());
     }
     return *mFullPathPtr;
 }
コード例 #18
0
ファイル: file.cpp プロジェクト: tranleduy2000/aapt_android
 std::string GetExecutableDirectory() {
     return Dirname(GetExecutablePath());
 }
コード例 #19
0
int main(int argc, const char **argv, char * const *envp)
{
    // Path
    void *MainAddr = (void*) (intptr_t) GetExecutablePath;
    llvm::sys::Path Path = GetExecutablePath(argv[0]);

    // DiagnosticOptions
    DiagnosticOptions diagnosticOptions;

    // DiagnosticClient
    TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::outs(), diagnosticOptions);

    // Diagnostic
    llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
    Diagnostic diagnostic(DiagID, DiagClient);


    //DiagnosticOptions DiagOpts;
    //llvm::IntrusiveRefCntPtr<Diagnostic> diagnostic = CompilerInstance::createDiagnostics(DiagOpts, argc, argv);

    // LangOptions
    LangOptions langOptions;
    langOptions.CPlusPlus = 1;
    langOptions.CPlusPlus0x = 1;
    langOptions.Microsoft = 1;
    langOptions.Bool = 1;
    langOptions.Exceptions = 1;
    langOptions.CXXExceptions = 1;
    langOptions.EmitAllDecls = 1;

    // FileManager
    FileSystemOptions fileSystemOptions;
    FileManager fileManager(fileSystemOptions);

    // SourceManager
    SourceManager sourceManager(diagnostic, fileManager);

    // HeadderSearch
    HeaderSearch headerSearch(fileManager);

    // TargetOptions
    TargetOptions targetOptions;
    targetOptions.Triple = llvm::sys::getHostTriple();

    // TargetInfo
    TargetInfo *pTargetInfo =
        TargetInfo::CreateTargetInfo(
            diagnostic,
            targetOptions);

    // HeaderSearchOptions
    HeaderSearchOptions headerSearchOptions;
    ApplyHeaderSearchOptions(
        headerSearch,
        headerSearchOptions,
        langOptions,
        pTargetInfo->getTriple());

    // Preprocessor
    Preprocessor preprocessor(
        diagnostic,
        langOptions,
        *pTargetInfo,
        sourceManager,
        headerSearch);

    // PreprocessorOptions
    PreprocessorOptions preprocessorOptions;
    preprocessorOptions.DetailedRecord = true;
    preprocessor.createPreprocessingRecord();

    // FrontendOptions
    FrontendOptions frontendOptions;


    // InitializePreprocessor
    InitializePreprocessor(
        preprocessor,
        preprocessorOptions,
        headerSearchOptions,
        frontendOptions);

    //preprocessor.SetCommentRetentionState(true, true);

    // Tutorial
    const FileEntry *pFile = fileManager.getFile(
                                 "test.cpp",
                                 true);
    sourceManager.createMainFileID(pFile);


    /*preprocessor.EnterMainSourceFile();
    Token Tok;
    do {
    	preprocessor.Lex(Tok);  // read one token
    	//if (context.diags.hasErrorOccurred())  // stop lexing/pp on error
    	//	break;
    	preprocessor.DumpToken(Tok);  // outputs to cerr
    	std::cerr << std::endl;
    } while (Tok.isNot(tok::eof));*/


    const TargetInfo &targetInfo = *pTargetInfo;

    IdentifierTable identifierTable(langOptions);
    SelectorTable selectorTable;

    Builtin::Context builtinContext(targetInfo);
    ASTContext astContext(
        langOptions,
        sourceManager,
        targetInfo,
        identifierTable,
        selectorTable,
        builtinContext,
        0 /* size_reserve*/);
    // ASTConsumer astConsumer;
    MyASTConsumer astConsumer;
    astConsumer.sourceManager = &sourceManager;
    astConsumer.html = new ClangDocHTML;
    astConsumer.html->astConsumer = &astConsumer;
    preprocessor.addPPCallbacks(astConsumer.html);
    preprocessor.AddCommentHandler(astConsumer.html);

    Sema sema(
        preprocessor,
        astContext,
        astConsumer);
    sema.Initialize();

    //MySemanticAnalisys mySema( preprocessor, astContext, astConsumer);

    //Parser parser( preprocessor, sema);
    //parser.ParseTranslationUnit();
    astConsumer.preprocessor = &sema.PP;
    ParseAST(preprocessor, &astConsumer, astContext);
    return 0;
}