• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ filesystem::path类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: absolute

void MaterialItem::slot_export()
{
    const char* project_path = m_editor_context.m_project.get_path();
    const filesystem::path project_root_path = filesystem::path(project_path).parent_path();
    const filesystem::path file_path = absolute("material.dmt", project_root_path);
    const filesystem::path file_root_path = file_path.parent_path();

    QString filepath =
        get_save_filename(
            0,
            "Export...",
            "Disney Materials (*.dmt)",
            m_editor_context.m_settings,
            SETTINGS_FILE_DIALOG_PROJECTS);

    if (!filepath.isEmpty())
    {
        if (QFileInfo(filepath).suffix().isEmpty())
            filepath += ".dmt";

        filepath = QDir::toNativeSeparators(filepath);

        ParamArray parameters = m_entity->get_parameters();
        parameters.insert("__name", m_entity->get_name());
        parameters.insert("__model", m_entity->get_model());

        SettingsFileWriter writer;
        if (!writer.write(filepath.toStdString().c_str(), parameters))
        {
            show_error_message_box(
                "Exporting Error",
                "Failed to export the Disney Material file " + filepath.toStdString() + ".");
        }
    }
}
开发者ID:caomw,项目名称:appleseed,代码行数:35,代码来源:materialitem.cpp


示例2: assert

void MainWindow::slot_save_project_as()
{
    assert(m_project_manager.is_project_open());

    QFileDialog::Options options;
    QString selected_filter;

    QString filepath =
        QFileDialog::getSaveFileName(
            this,
            "Save As...",
            m_settings.get_path_optional<QString>(LAST_DIRECTORY_SETTINGS_KEY),
            "Project Files (*.appleseed)",
            &selected_filter,
            options);

    if (!filepath.isEmpty())
    {
        filepath = QDir::toNativeSeparators(filepath);

        const filesystem::path path(filepath.toStdString());

        m_settings.insert_path(
            LAST_DIRECTORY_SETTINGS_KEY,
            path.parent_path().string());

        m_project_manager.save_project_as(filepath.toAscii().constData());

        update_recent_files_menu(filepath);
        update_workspace();
    }
}
开发者ID:EgoIncarnate,项目名称:appleseed,代码行数:32,代码来源:mainwindow.cpp


示例3: s_abs_path

	static std::wstring s_abs_path(const filesystem::path& file)
	{
		if (!file.is_absolute())
			return (s_path / file).wstring();
		else
			return file.wstring();
	}
开发者ID:eh2k,项目名称:teapot-viewer,代码行数:7,代码来源:SceneIO.cpp


示例4: xmlfile_listener

void BenchmarkRunnerThread::run()
{
    auto_release_ptr<XMLFileBenchmarkListener> xmlfile_listener(
        create_xmlfile_benchmark_listener());

    const string xmlfile_name = "benchmark." + get_time_stamp_string() + ".xml";
    const filesystem::path xmlfile_path =
          filesystem::path(Application::get_tests_root_path())
        / "unit benchmarks"
        / "results"
        / xmlfile_name;

    if (!xmlfile_listener->open(xmlfile_path.string().c_str()))
    {
        emit signal_cannot_create_benchmark_file();
        return;
    }

    BenchmarkResult result;
    result.add_listener(xmlfile_listener.get());

    const filesystem::path old_current_path =
        Application::change_current_directory_to_tests_root_path();

    BenchmarkSuiteRepository::instance().run(result);

    filesystem::current_path(old_current_path);

    emit signal_finished();
}
开发者ID:yesoce,项目名称:appleseed,代码行数:30,代码来源:benchmarkrunnerthread.cpp


示例5: filepath

void GenericMeshFileReader::read(IMeshBuilder& builder)
{
    const filesystem::path filepath(impl->m_filename);
    const string extension = lower_case(filepath.extension().string());

    if (extension == ".obj")
    {
        OBJMeshFileReader reader(impl->m_filename, impl->m_obj_options);
        reader.read(builder);
    }
    else if (extension == ".abc")
    {
        AlembicMeshFileReader reader(impl->m_filename);
        reader.read(builder);
    }
    else if (extension == ".binarymesh")
    {
        BinaryMeshFileReader reader(impl->m_filename);
        reader.read(builder);
    }
    else
    {
        throw ExceptionUnsupportedFileFormat(impl->m_filename.c_str());
    }
}
开发者ID:hipopotamo-hipotalamo,项目名称:appleseed,代码行数:25,代码来源:genericmeshfilereader.cpp


示例6: treeWidget

void TextureCollectionItem::slot_import_textures()
{
    QFileDialog::Options options;
    QString selected_filter;

    const QStringList filepaths =
        QFileDialog::getOpenFileNames(
            treeWidget(),
            "Import Textures...",
            m_settings.get_path_optional<QString>(LAST_DIRECTORY_SETTINGS_KEY),
            "Texture Files (*.exr);;All Files (*.*)",
            &selected_filter,
            options);

    if (filepaths.empty())
        return;

    const filesystem::path path(
        QDir::toNativeSeparators(filepaths.first()).toStdString());

    m_settings.insert_path(
        LAST_DIRECTORY_SETTINGS_KEY,
        path.parent_path().string());

    for (int i = 0; i < filepaths.size(); ++i)
    {
        const string filepath = QDir::toNativeSeparators(filepaths[i]).toStdString();
        m_project_builder.insert_texture(m_parent, m_parent_item, filepath);
    }
}
开发者ID:Len3d,项目名称:appleseed,代码行数:30,代码来源:texturecollectionitem.cpp


示例7: GetFilenameWithoutExtension

        std::string GetFilenameWithoutExtension(const filesystem::path& filePath)
        {
            auto extension = filePath.extension();
            auto filename = filePath.filename();

            return !extension.empty() ? filename.substr(0, filename.length() - extension.length() - 1) : filename;
        }
开发者ID:eparayre,项目名称:blueprint,代码行数:7,代码来源:Parser.cpp


示例8: main

int main(int argc, const char* argv[])
{
    SuperLogger logger;

    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    global_logger().add_target(&logger.get_log_target());

    // Construct the schema filename.
    const filesystem::path schema_path =
          filesystem::path(Application::get_root_path())
        / "schemas/project.xsd";

    // Load the input project from disk.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            cl.m_filename.values()[0].c_str(),
            schema_path.file_string().c_str()));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Write the project back to disk.
    return ProjectFileWriter::write(project.ref()) ? 0 : 1;
}
开发者ID:tomcodes,项目名称:appleseed,代码行数:30,代码来源:main.cpp


示例9: osPath

string Utils::osPath(const filesystem::path &path)
{
#ifdef __WIN32__
	return nowide::narrow(path.generic_wstring());
#else
	return path.generic_string();
#endif
}
开发者ID:akashrajkn,项目名称:jasp-desktop,代码行数:8,代码来源:utils.cpp


示例10: RENDERER_LOG_INFO

void RenderingManager::archive_frame_to_disk()
{
    RENDERER_LOG_INFO("archiving frame to disk...");

    const filesystem::path autosave_path =
          filesystem::path(Application::get_root_path())
        / "images" / "autosave";

    m_project->get_frame()->archive(autosave_path.string().c_str());
}
开发者ID:hipopotamo-hipotalamo,项目名称:appleseed,代码行数:10,代码来源:renderingmanager.cpp


示例11: reload_benchmarks

void BenchmarkWindow::reload_benchmarks()
{
    const filesystem::path benchmarks_path =
          filesystem::path(Application::get_tests_root_path())
        / "unit benchmarks/results/";

    m_benchmark_aggregator.clear();
    m_benchmark_aggregator.scan_directory(benchmarks_path.string().c_str());

    populate_benchmarks_treeview();
}
开发者ID:willzhou,项目名称:appleseed,代码行数:11,代码来源:benchmarkwindow.cpp


示例12: makePathCompact

void makePathCompact(const filesystem::path& path, filesystem::path& out_compact)
{
    out_compact.clear();
        
    for(filesystem::path::const_iterator p = path.begin(); p != path.end(); ++p){
        if(*p == ".."){
            out_compact = out_compact.parent_path();
        } else if(*p != "."){
            out_compact /= *p;
        }
    }
}
开发者ID:kayusawa,项目名称:choreonoid,代码行数:12,代码来源:FileUtil.cpp


示例13: setupEmptyDirectory

void Renderer::setupEmptyDirectory(const filesystem::path &path) {
    FileUtils::createDir(path.str());
    tinydir_dir dir;
    tinydir_open_sorted(&dir, path.str().c_str());
    for (size_t i = 0; i < dir.n_files; ++i) {
        tinydir_file file;
        tinydir_readfile_n(&dir, &file, i);
        if (file.is_reg) {
            FileUtils::deleteFile((path / file.name).str());
        }
    }
    tinydir_close(&dir);
}
开发者ID:Seashell2011,项目名称:pbsproject,代码行数:13,代码来源:Renderer.cpp


示例14: main

int main(int argc, const char* argv[])
{
    SuperLogger logger;
    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    // Initialize the renderer's logger.
    global_logger().add_target(&logger.get_log_target());

    // Retrieve the input file path.
    const string& input_filepath = cl.m_filename.value();

    // Construct the schema file path.
    const filesystem::path schema_filepath =
          filesystem::path(Application::get_root_path())
        / "schemas"
        / "project.xsd";

    // Read the input project from disk.
    // Note: it is crucial that we read mesh files as well, so that we can collect
    // material slots declared by objects. Material slots are required by the project
    // file updater, for instance when migrating projects from rev. 7 to rev. 8.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            input_filepath.c_str(),
            schema_filepath.string().c_str(),
            ProjectFileReader::OmitProjectFileUpdate));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Update the project file to the desired revision.
    ProjectFileUpdater updater;
    if (cl.m_to_revision.is_set())
        updater.update(project.ref(), cl.m_to_revision.value());
    else updater.update(project.ref());

    // Write the project back to disk.
    const bool success =
        ProjectFileWriter::write(
            project.ref(),
            project->get_path(),
            ProjectFileWriter::OmitWritingGeometryFiles | ProjectFileWriter::OmitBringingAssets);

    return success ? 0 : 1;
}
开发者ID:docwhite,项目名称:appleseed,代码行数:50,代码来源:main.cpp


示例15: path

void MainWindow::open_project(const QString& filepath)
{
    const filesystem::path path(filepath.toStdString());

    m_settings.insert_path(
        LAST_DIRECTORY_SETTINGS_KEY,
        path.parent_path().string());

    const bool successful =
        m_project_manager.load_project(filepath.toAscii().constData());

    if (successful)
        on_project_change();
    else  show_project_file_loading_failed_message_box(this, filepath);
}
开发者ID:EgoIncarnate,项目名称:appleseed,代码行数:15,代码来源:mainwindow.cpp


示例16: EnsureDirectoryExists

 void EnsureDirectoryExists(const filesystem::path& directory)
 {
     if (!directory.is_directory())
     {
         filesystem::create_directory(directory);
     }
 }
开发者ID:eparayre,项目名称:blueprint,代码行数:7,代码来源:Parser.cpp


示例17: ParseWorkspace

    bool Parser::ParseWorkspace(const filesystem::path& filePath)
    {
        if (filePath.str().empty())
        {
            std::cout << "invalid workspace filename" << std::endl;
            return false;
        }

        WorkingDirectory::SetCurrent(filePath.make_absolute().parent_path().str());
        std::cout << "{ cwd : " << WorkingDirectory::GetCurrent() << " }" << std::endl;

        internal::EnsureDirectoryExists(outputDirectory_);

        auto workspace = JsonImporter::ImportWorkspace(pimpl_->GetFileManager(), filePath.filename());
        return ParseWorkspace(workspace.get());
    }
开发者ID:eparayre,项目名称:blueprint,代码行数:16,代码来源:Parser.cpp


示例18: open

	bool FLogSource::open(const filesystem::path& path)
	{
		Synchronize on(*this);
		m_path = path.native();
		std::fstream log{ m_path, std::ios_base::out | std::ios_base::app };
		return log.is_open();
	}
开发者ID:mbits-os,项目名称:libenv,代码行数:7,代码来源:application.cpp


示例19:

std::unique_ptr<Workspace> JsonImporter::ImportWorkspace(FileManager& fileManager, const filesystem::path& workspaceFile)
{
    auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), workspaceFile);

    if (internal::IsValidWorkspace(json))
    {
        auto workspace = std::make_unique<Workspace>();

        workspace->SetName(json["workspace"]);
        workspace->SetFile(workspaceFile);

        auto& projects = json["projects"];

        if (projects.is_array())
        {
            auto workspacePath = workspaceFile.parent_path();

            for (auto& project : projects)
            {
                workspace->AddProject(ImportProject(fileManager, workspacePath / project));
            }
        }

        return workspace;
    }

    return nullptr;
}
开发者ID:eparayre,项目名称:blueprint,代码行数:28,代码来源:JsonImporter.cpp


示例20: mpw_path

fs::path mpw_path() {

	static fs::path path;

	if (path.empty()) {
		std::error_code ec;
		const char *cp = getenv("PATH");
		if (!cp) cp = _PATH_DEFPATH;
		std::string s(cp);
		string_splitter ss(s, ':');
		for (; ss; ++ss) {
			if (ss->empty()) continue;
			fs::path p(*ss);
			p /= "mpw";

			if (fs::is_regular_file(p, ec)) {
				path = std::move(p);
				break;
			}
		}
		//also check /usr/local/bin
		if (path.empty()) {
			fs::path p = "/usr/local/bin/mpw";
			if (fs::is_regular_file(p, ec)) {
				path = std::move(p);
			}
		}

		if (path.empty()) {
			fs::path p = root() / "bin/mpw";
			if (fs::is_regular_file(p, ec)) {
				path = std::move(p);
			}
		}

		if (path.empty()) {
			fprintf(stderr, "Unable to find mpw executable\n");
			fprintf(stderr, "PATH = %s\n", s.c_str());
			path = "mpw";
		}
	}

	return path;
}
开发者ID:ksherlock,项目名称:mpw-shell,代码行数:44,代码来源:mpw-shell.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ filter::Lock类代码示例发布时间:2022-05-31
下一篇:
C++ file::IOFile类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap