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


C++ FilePath::Append方法代码示例

本文整理汇总了C++中FilePath::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::Append方法的具体用法?C++ FilePath::Append怎么用?C++ FilePath::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilePath的用法示例。


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

示例1: PathProvider


//.........这里部分代码省略.........
                // 代码调用的模块都有资源, 无论dll或exe.
                HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
                GetModuleFileNameW(this_module, system_buffer, MAX_PATH);
                cur = FilePath(system_buffer);
                break;
            }
        case DIR_WINDOWS:
            GetWindowsDirectoryW(system_buffer, MAX_PATH);
            cur = FilePath(system_buffer);
            break;
        case DIR_SYSTEM:
            GetSystemDirectoryW(system_buffer, MAX_PATH);
            cur = FilePath(system_buffer);
            break;
        case DIR_PROGRAM_FILES:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_IE_INTERNET_CACHE:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_INTERNET_CACHE, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_COMMON_START_MENU:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_COMMON_PROGRAMS, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_START_MENU:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_PROGRAMS, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_COMMON_APP_DATA:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_APP_DATA:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_PROFILE:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        case DIR_LOCAL_APP_DATA_LOW:
            if(GetWinVersion() < WINVERSION_VISTA)
            {
                return false;
            }
            // TODO: 应该使用SHGetKnownFolderPath替换. Bug 1281128.
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            cur.RemoveFileSpec();
            cur.Append(L"LocalLow");
            break;
        case DIR_LOCAL_APP_DATA:
            if(FAILED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL,
                SHGFP_TYPE_CURRENT, system_buffer)))
            {
                return false;
            }
            cur = FilePath(system_buffer);
            break;
        default:
            return false;
        }

        *result = cur;
        return true;
    }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:101,代码来源:path_service.cpp

示例2: init

bool Root::init(FileString homeDirectory, FileString subprocessDirectory, unsigned int extra_argc, const char* extra_argv[] ) {

    new base::AtExitManager();

    FilePath subprocess;

    // convert extra arguments in a more useful form
    std::vector< std::string > extra_args;
    if( extra_argc > 0 )
    {
        for( unsigned int arg_idx = 0; arg_idx < extra_argc; ++arg_idx )
        {
            const char* raw_arg = extra_argv[ arg_idx ];
            assert( raw_arg );
            extra_args.push_back( raw_arg );
        }
    }


    {
// From <base/command_line.h>:
  // Initialize the current process CommandLine singleton.  On Windows,
  // ignores its arguments (we instead parse GetCommandLineW()
  // directly) because we don't trust the CRT's parsing of the command
  // line, but it still must be called to set up the command line.
// This means that on windows, we have to call ::Init with whatever we feel
// like (since this is the only way to create the static CommandLine instance),
// and then we have manually call ParseFromString.
// (InitFromArgv does not exist on OS_WIN!)
#if defined(OS_WIN)
    FilePath module_dir;
    if (subprocessDirectory.size()) {
        module_dir = FilePath(subprocessDirectory.get<FilePath::StringType>());
    } else {
        PathService::Get(base::DIR_MODULE, &module_dir);
    }
#ifdef _DEBUG
    subprocess = module_dir.Append(L"berkelium_d.exe");
#else
    subprocess = module_dir.Append(L"berkelium.exe");
#endif

	std::wstring subprocess_str = L"berkelium --enable-webgl --browser-subprocess-path=";
	subprocess_str += L"\"";
	subprocess_str += subprocess.value();
	subprocess_str += L"\"";

    // add extra arguments if any
    if( !extra_args.empty() )
    {
        for( unsigned int arg_idx = 0, arg_count = extra_args.size(); arg_idx < arg_count; ++arg_idx )
        {
            const std::string& str_arg = extra_args[ arg_idx ];
            std::wstring wstr_arg( str_arg.begin(), str_arg.end() );

            subprocess_str += L" " + wstr_arg;
        }
    }

    //std::wcout << "Berkelium subprocess_str : " << subprocess_str;

    CommandLine::Init(0, NULL);
    CommandLine::ForCurrentProcess()->ParseFromString(subprocess_str);
#elif defined(OS_MACOSX)
    FilePath app_contents;
    PathService::Get(base::FILE_EXE, &app_contents);
    FilePath module_dir;
    if (subprocessDirectory.size()) {
        module_dir = FilePath(subprocessDirectory.get<FilePath::StringType>());
    } else {
        module_dir = app_contents.DirName();
    }
    subprocess = module_dir.Append("berkelium");
    std::string subprocess_str = "--browser-subprocess-path=";
    subprocess_str += subprocess.value();

    std::vector<const char*> argv;
    argv.push_back( "berkelium" );
    argv.push_back( subprocess_str.c_str() );
    argv.push_back( "--enable-webgl" );

    for( std::vector<std::string>::iterator it = extra_args.begin(); it != extra_args.end(); ++it )
    {
        argv.push_back( it->c_str() );
    }

    //for( std::vector<const char*>::iterator it = argv.begin(); it != argv.end(); ++it )
    //    std::cout << "Berkelium arg : " << *it;

    CommandLine::Init( argv.size(), &argv[0] );
#elif defined(OS_POSIX)
    FilePath module_file;
    PathService::Get(base::FILE_EXE, &module_file);
    FilePath module_dir;
    if (subprocessDirectory.size()) {
        module_dir = FilePath(subprocessDirectory.get<FilePath::StringType>());
    } else {
        module_dir = module_file.DirName();
    }
    subprocess = module_dir.Append("berkelium");
//.........这里部分代码省略.........
开发者ID:cnxsoft,项目名称:xibo4arm,代码行数:101,代码来源:Root.cpp


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