当前位置: 首页>>代码示例>>C++>>正文


C++ PathJoin函数代码示例

本文整理汇总了C++中PathJoin函数的典型用法代码示例。如果您正苦于以下问题:C++ PathJoin函数的具体用法?C++ PathJoin怎么用?C++ PathJoin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PathJoin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PathJoin

std::vector<SString> SharedUtil::FindFiles(const SString& strMatch, bool bFiles, bool bDirectories, bool bSortByDate)
{
    std::vector<SString>           strResult;
    std::multimap<uint64, SString> sortMap;

    DIR*           Dir;
    struct dirent* DirEntry;

    // Extract any filename matching characters
    SString strFileMatch;
    SString strSearchDirectory = PathJoin(PathConform(strMatch).SplitLeft("/", &strFileMatch, -1), "/");

    if ((Dir = opendir(strSearchDirectory)))
    {
        while ((DirEntry = readdir(Dir)) != NULL)
        {
            // Skip dotted entries
            if (strcmp(DirEntry->d_name, ".") && strcmp(DirEntry->d_name, ".."))
            {
                struct stat Info;
                bool        bIsDir = false;

                // Do wildcard matching if required
                if (!strFileMatch.empty() && !WildcardMatch(strFileMatch, DirEntry->d_name))
                {
                    continue;
                }

                SString strPath = PathJoin(strSearchDirectory, DirEntry->d_name);

                // Determine the file stats
                if (lstat(strPath, &Info) != -1)
                    bIsDir = S_ISDIR(Info.st_mode);

                if (bIsDir ? bDirectories : bFiles)
                {
                    if (bSortByDate)
                    {
                        SString     strAbsPath = strSearchDirectory + DirEntry->d_name;
                        struct stat attrib;
                        stat(strAbsPath, &attrib);
                        MapInsert(sortMap, (uint64)attrib.st_mtime, SStringX(DirEntry->d_name));
                    }
                    else
                        strResult.push_back(DirEntry->d_name);
                }
            }
        }
        closedir(Dir);
    }

    // Resolve sorted map if required
    if (!sortMap.empty())
    {
        for (std::multimap<uint64, SString>::iterator iter = sortMap.begin(); iter != sortMap.end(); ++iter)
            strResult.push_back(iter->second);
    }

    return strResult;
}
开发者ID:Necktrox,项目名称:mtasa-blue,代码行数:60,代码来源:SharedUtil.File.hpp

示例2: staticPathList

static void staticPathList(std::list<CString>& paths, std::set<CString>& folders, const CString& startDir, const CString& folder, BOOL recursive)
{
	CString strDirectory = PathJoin(startDir, folder);

	CFileFind finder;	
	BOOL bWorking = finder.FindFile(strDirectory + _T("\\*.*"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();

		CString filename = finder.GetFileName();

		if (filename == "." || filename == "..")
			continue;

		if (finder.IsDirectory())
		{
			if (recursive)
			{
				staticPathList(paths, folders, startDir, PathJoin(folder, filename), recursive);
			}
			folders.insert(PathJoin(folder, filename));
		}
		else
		{
			paths.push_back(PathJoin(folder, filename));
		}
	}
}
开发者ID:ror13,项目名称:diplom,代码行数:29,代码来源:FileHelpers.cpp

示例3: TestPath

void TestPath() {
  printf("TestPath()\n");
  assert(Canonicalize("", "") == "");
  assert(Canonicalize("", "baker") == "baker");
  assert(Canonicalize("able", "") == "able");
  assert(Canonicalize("able", "baker") == "able/baker");
  assert(Canonicalize("able/", "baker") == "able/baker");
  assert(Canonicalize("baker/charlie", "#delta") == "delta");
  assert(Canonicalize("baker/charlie", "#") == "");
  assert(Canonicalize("baker/charlie", "#../external") == "../external");
  assert(Canonicalize("baker/charlie", "..") == "baker");
  assert(Canonicalize("baker/charlie", "delta") == "baker/charlie/delta");
  assert(Canonicalize("baker/charlie", "../delta") == "baker/delta");
  assert(Canonicalize("baker/charlie/", "../delta") == "baker/delta");
  assert(Canonicalize("baker/charlie", "../../delta") == "delta");
  assert(Canonicalize("baker/charlie", "../..") == "");
  assert(Canonicalize("baker/charlie", "../../../external") == "../external");
  assert(Canonicalize("baker/charlie", "#:test") == ":test");

  assert(PathJoin("a/b/c", "x/y/z") == "a/b/c/x/y/z");
  assert(PathJoin("a/b/..", "x/y/z") == "a/b/../x/y/z");
  assert(PathJoin("../..", "../x/y/z") == "../../../x/y/z");

  assert(IsAbsolute("hello") == false);
  assert(IsAbsolute("hello/there") == false);
  assert(IsAbsolute("../hello") == false);
  assert(IsAbsolute("../../hello/there") == false);
  assert(IsAbsolute("/hello") == true);
  assert(IsAbsolute("c:/hello/there") == true);
  assert(IsAbsolute("C:/hello/there") == true);
  assert(IsAbsolute("c:\\hello\\there") == true);
  assert(IsAbsolute("C:\\hello\\there") == true);
}
开发者ID:prepare,项目名称:gameswf,代码行数:33,代码来源:path.cpp

示例4: GetSystemCurrentDirectory

void CCrashHandler::Init ( const SString& strInServerPath )
{
    SString strServerPath = strInServerPath;
    if ( strServerPath == "" )
        strServerPath = GetSystemCurrentDirectory();
    ms_strDumpPath = PathJoin( strServerPath, SERVER_DUMP_PATH );

    // Set a global filter
    #ifdef WIN32
        SetCrashHandlerFilter ( HandleExceptionGlobal );
    #else
        // Prepare initial dumpfile name
        time_t pTime = time( NULL );
        struct tm* tm = localtime( &pTime );
        SString strFilename( "server_%s_%04d%02d%02d_%02d%02d.dmp",
                                        MTA_DM_BUILDTAG_LONG,
                                        tm->tm_year + 1900,
                                        tm->tm_mon + 1,
                                        tm->tm_mday,
                                        tm->tm_hour,
                                        tm->tm_min
                                    );
        ms_strDumpPathFilename = PathJoin( ms_strDumpPath, strFilename );
        MakeSureDirExists( ms_strDumpPathFilename );

        #ifdef WITH_BACKTRACE_ONLY
            signal ( SIGSEGV, HandleExceptionGlobal );
        #else
            google_breakpad::MinidumpDescriptor descriptor( ms_strDumpPath );
            static google_breakpad::ExceptionHandler eh( descriptor, NULL, DumpCallback, NULL, true, -1 );
        #endif
    #endif
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:33,代码来源:CCrashHandler.cpp

示例5: FindHeader

// Searches for an existing header file.  Returns true and fills in
// *header_path if it finds one.
bool FindHeader(const string& src_dir, const Target* t,
                const Context* context, const string& header_file,
                bool is_quoted, string* header_path) {
    // TODO: handle absolute header file names,
    // (e.g. #include "/abs/path/header.h" or "c:/somefile.h")

    if (is_quoted) {
        // First look in the directory where the source file was found.
        string path = PathJoin(src_dir, header_file);
        if (FileExists(path)) {
            *header_path = path;
            return true;
        }
    }

    for (size_t i = 0; i < t->inc_dirs().size(); i++) {
        // TODO: handle absolute inc_dirs
        string path = PathJoin(context->tree_root(), t->inc_dirs()[i]);
        path = PathJoin(path, header_file);
        if (FileExists(path)) {
            *header_path = path;
            return true;
        }
    }
    return false;
}
开发者ID:weihuoya,项目名称:gameswf,代码行数:28,代码来源:file_deps.cpp

示例6: DumpCallback

// Linux crash callback when using google-breakpad
bool DumpCallback( const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded )
{
    // Set inital dump file name (Safeish)
    File::Rename( descriptor.path(), ms_strDumpPathFilename );

    // Set final dump file name (Not so safe)
    time_t pTime = time( NULL );
    struct tm* tm = localtime( &pTime );
    SString strFilename( "server_%s_%04d%02d%02d_%02d%02d.dmp",
                                    MTA_DM_BUILDTAG_LONG,
                                    tm->tm_year + 1900,
                                    tm->tm_mon + 1,
                                    tm->tm_mday,
                                    tm->tm_hour,
                                    tm->tm_min
                                );
    SString strFinalDumpPathFilename = PathJoin( ms_strDumpPath, strFilename );
    File::Rename( ms_strDumpPathFilename, strFinalDumpPathFilename );

    SaveBacktraceSummary();
    FileSave( PathJoin( ms_strDumpPath, "server_pending_upload_filename" ), strFinalDumpPathFilename );

    // Return false to indicate exception has not been handled (and allow core dump?)
    return false;
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:26,代码来源:CCrashHandler.cpp

示例7: PathJoin

SString CResourceFile::GetCachedPathFilename(bool bForceClientCachePath)
{
    if (IsNoClientCache() == false || bForceClientCachePath)
        return PathJoin(g_pServerInterface->GetServerModPath(), "resource-cache", "http-client-files", m_resource->GetName(), GetName());
    else
        return PathJoin(g_pServerInterface->GetServerModPath(), "resource-cache", "http-client-files-no-client-cache", m_resource->GetName(), GetName());
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:7,代码来源:CResourceFile.cpp

示例8: PathJoin

void MUSImporter::PlayMusic(char* name)
{
	char FName[_MAX_PATH];
	if (strnicmp( name, "mx9000", 6 ) == 0) { //iwd2
		PathJoin(FName, "mx9000", name, NULL);
	} else if (strnicmp( name, "mx0000", 6 ) == 0) { //iwd
		PathJoin(FName, "mx0000", name, NULL);
	} else if (strnicmp( name, "SPC", 3 ) != 0) { //bg2
		char File[_MAX_PATH];
		snprintf(File, _MAX_PATH, "%s%s", PLName, name);
		PathJoin(FName, PLName, File, NULL);
	} else {
		strncpy(FName, name, _MAX_PATH);
	}

	ResourceHolder<SoundMgr> sound(FName, manager);
	if (sound) {
		int soundID = core->GetAudioDrv()->CreateStream( sound );
		if (soundID == -1) {
			core->GetAudioDrv()->Stop();
		}
	} else {
		core->GetAudioDrv()->Stop();
	}
	printf( "Playing: %s\n", FName );
}
开发者ID:NickDaly,项目名称:GemRB-MultipleConfigs,代码行数:26,代码来源:MUSImporter.cpp

示例9: SaveBacktraceSummary

static void SaveBacktraceSummary()
{
    // Collect backtrace information
    void * buffer [ 100 ];
    int iAmount = backtrace ( buffer, sizeof buffer );
    iAmount = std::min < int > ( iAmount, NUMELMS( buffer ) );
    char ** symbols = backtrace_symbols ( buffer, iAmount );

    // Generate a .log file
    time_t pTime = time ( NULL );
    struct tm * tm = localtime ( &pTime );

    SString sFileName;
    sFileName.Format ( "server_%s_%04d%02d%02d_%02d%02d.log", MTA_DM_BUILDTYPE, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min );

    SString sContent;
    sContent += SString ( "MTA:SA Server v%s-r%d-%s crash report.\n", MTA_DM_VERSIONSTRING, MTASA_VERSION_BUILD, MTA_DM_BUILDTYPE );
    sContent += SString ( "%04d-%02d-%02d %02d:%02d\n", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min );
    sContent += SString ( "Caught %d addresses ...\n\n", iAmount );
    sContent += "Backtrace:\n";

    for ( int i = 0; i < iAmount; i++ )
    {
        if ( symbols [ i ] )
        {
            sContent += SString ( "#%d - %s\n", i, symbols [ i ] );
        }
    }
    sContent += std::string( 80, '-' ) + "\n";

    // Write the content to the file and close
    MakeSureDirExists ( PathJoin( ms_strDumpPath, sFileName ) );
    FileAppend( PathJoin( ms_strDumpPath, sFileName ), sContent );
    FileAppend( PathJoin( ms_strDumpPath, "server_pending_upload.log" ), sContent );

    free ( symbols );

    // Try to close window gracefully 
    if ( !g_bSilent && !g_bNoCurses && m_wndInput )
    {
        if ( m_wndMenu )
        {
            delwin ( m_wndMenu );
            m_wndMenu = NULL;
        }
        delwin ( m_wndInput );
        m_wndInput = NULL;
        endwin ( );
    }
}
开发者ID:Jusonex,项目名称:mtasa-blue,代码行数:50,代码来源:CCrashHandler.cpp

示例10: GetApplicationSetting

//////////////////////////////////////////////////////////
//
// CInstallManager::_InstallNewsItems
//
//
//
//////////////////////////////////////////////////////////
SString CInstallManager::_InstallNewsItems ( void )
{
    // Get install news queue
    CArgMap queue;
    queue.SetFromString ( GetApplicationSetting ( "news-install" ) );
    SetApplicationSetting ( "news-install", "" );

    std::vector < SString > keyList;
    queue.GetKeys ( keyList );
    for ( uint i = 0 ; i < keyList.size () ; i++ )
    {
        // Install each file
        SString strDate = keyList[i];
        SString strFileLocation = queue.Get ( strDate );

        // Save cwd
        SString strSavedDir = GetSystemCurrentDirectory ();

        // Calc and make target dir
        SString strTargetDir = PathJoin ( GetMTADataPath (), "news", strDate );
        MkDir ( strTargetDir );

        // Extract into target dir
        SetCurrentDirectory ( strTargetDir );

        // Try to extract the files
        if ( !ExtractFiles ( strFileLocation ) )
        {
            // If extract failed and update file is an exe, try to run it
            if ( ExtractExtension ( strFileLocation ).CompareI ( "exe" ) )
                ShellExecuteBlocking ( "open", strFileLocation, "-s" );
        }

        // Restore cwd
        SetCurrentDirectory ( strSavedDir );

        // Check result
        if ( FileExists ( PathJoin ( strTargetDir, "files.xml" ) ) )
        {
            SetApplicationSettingInt ( "news-updated", 1 );
            AddReportLog ( 2051, SString ( "InstallNewsItems ok for '%s'", *strDate ) );
        }
        else
        {
            AddReportLog ( 4048, SString ( "InstallNewsItems failed with '%s' '%s' '%s'", *strDate, *strFileLocation, *strTargetDir ) );
        }
    }
    return "ok";
}
开发者ID:ntauthority,项目名称:openvice,代码行数:56,代码来源:CInstallManager.cpp

示例11: PathJoin

///////////////////////////////////////////////////////////////
//
// CServerIdManagerImpl::CServerIdManagerImpl
//
//
//
///////////////////////////////////////////////////////////////
CServerIdManagerImpl::CServerIdManagerImpl ( void )
{
    // Calc private dir root
    m_strServerIdLookupBaseDir = PathJoin ( g_pClientGame->GetFileCacheRoot(), MTA_SERVERID_LOOKUP_DIR );
    MakeSureDirExists ( PathJoin ( m_strServerIdLookupBaseDir, "" ) );

    // Calc temp dir path incase of server id error
    m_strTempErrorDir = PathJoin ( m_strServerIdLookupBaseDir, "_error" );

    // If temp dir has been used, clean it
    if ( DirectoryExists ( m_strTempErrorDir ) )
        DelTree ( m_strTempErrorDir, m_strServerIdLookupBaseDir );

    LoadServerIdMap ();
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:22,代码来源:CServerIdManager.cpp

示例12: PathJoin

CachedFileStream::CachedFileStream(CachedFileStream* cfs, int startpos,
	int size, bool autoFree)
{
	this->size = size;
	this->startpos = startpos;
	this->autoFree = autoFree;
	char cpath[_MAX_PATH];
	PathJoin( cpath, core->CachePath, cfs->filename, NULL );
	str = _fopen( cpath, "rb" );
	if (str == NULL) {
		str = _fopen( cfs->originalfile, "rb" );
		if (str == NULL) {
			printf( "Can't open stream (maybe leaking?)\n" );
			return;
		}
		strncpy( originalfile, cfs->originalfile, sizeof(originalfile) );
		strncpy( filename, cfs->filename, sizeof(filename) );
	} else {
		strncpy( originalfile, cpath, sizeof(originalfile) );
		strncpy( filename, cfs->filename, sizeof(filename) );
	}
#ifdef _DEBUG
	core->CachedFileStreamPtrCount++;
#endif
	_fseek( str, startpos, SEEK_SET );
	
	
	Pos = 0;
}
开发者ID:NickDaly,项目名称:GemRB-MultipleConfigs,代码行数:29,代码来源:CachedFileStream.cpp

示例13: GetWMITotalPhysicalMemory

//
// Toggle hook on/off.
// Enable caching and faster loading of clothes files
//
void CMultiplayerSA::SetFastClothesLoading(EFastClothesLoading fastClothesLoading)
{
    if (m_FastClothesLoading == fastClothesLoading)
        return;

    m_FastClothesLoading = fastClothesLoading;

    // Handle auto setting
    if (fastClothesLoading == FAST_CLOTHES_AUTO)
    {
        // Disable if less than 512MB installed ram
        long long llSystemRamKB = GetWMITotalPhysicalMemory() / 1024LL;
        if (llSystemRamKB > 0 && llSystemRamKB < 512 * 1024)
            fastClothesLoading = FAST_CLOTHES_OFF;
    }

    if (fastClothesLoading != FAST_CLOTHES_OFF)
    {
        // Load and cache player.img
        SString strGTASAPath = GetCommonRegistryValue("", "GTA:SA Path");
        SString strFilename = PathJoin(strGTASAPath, "models", "player.img");
        FileLoad(strFilename, m_PlayerImgCache);
    }
    else
    {
        // Remove cached data - Note: This method ensures the memory is actually freed
        std::vector<char>().swap(m_PlayerImgCache);
    }

    // Update the cache pointer
    if (!m_PlayerImgCache.empty())
        ms_PlayerImgCachePtr = &m_PlayerImgCache[0];
    else
        ms_PlayerImgCachePtr = NULL;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:39,代码来源:CMultiplayerSA_ClothesSpeedUp.cpp

示例14: PathJoin

//////////////////////////////////////////////////////////
//
// CInstallManager::GetLauncherPathFilename
//
// Get path to launch exe
//
//////////////////////////////////////////////////////////
SString CInstallManager::GetLauncherPathFilename ( void )
{
    SString strLocation = m_pSequencer->GetVariable ( INSTALL_LOCATION );
    SString strResult = PathJoin ( strLocation == "far" ? GetSystemCurrentDirectory () : GetMTASAPath (), MTA_EXE_NAME );
    AddReportLog ( 1062, SString ( "GetLauncherPathFilename %s", *strResult ) );
    return strResult;
}
开发者ID:ntauthority,项目名称:openvice,代码行数:14,代码来源:CInstallManager.cpp

示例15: while

std::vector < SString > SharedUtil::FindFiles ( const SString& strMatch, bool bFiles, bool bDirectories )
{
    std::vector < SString > strResult;

    DIR *Dir;
    struct dirent *DirEntry;

    if ( ( Dir = opendir ( strMatch ) ) )
    {
        while ( ( DirEntry = readdir ( Dir ) ) != NULL )
        {
            // Skip dotted entries
            if ( strcmp ( DirEntry->d_name, "." ) && strcmp ( DirEntry->d_name, ".." ) )
            {
                struct stat Info;
                bool bIsDir = false;

                SString strPath = PathJoin ( strMatch, DirEntry->d_name );

                // Determine the file stats
                if ( lstat ( strPath, &Info ) != -1 )
                    bIsDir = S_ISDIR ( Info.st_mode );

                if ( bIsDir ? bDirectories : bFiles )
                    strResult.push_back ( DirEntry->d_name );
            }
        }
    }
    return strResult;
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:30,代码来源:SharedUtil.File.hpp


注:本文中的PathJoin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。