C++ filesystem

C++ filesystem命名空间:std::tr2::sys头文件:#include1.路径或文件是否存在templateinlineboolexists(constPath&Pval);std::tr2::sys::pathmyfile(R”(D:\胡军军\TestStatu.xm)”); if(std::tr2::sys::exists(myfile)){  

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

命名空间: std::tr2::sys

头文件:

#include <filesystem>

Jetbrains全家桶1年46,售后保障稳定

1.路径或文件是否存在

template<class Path>inline bool exists( const Path& Pval); 

std::tr2::sys::path myfile(R"(D:\胡军军\TestStatu.xm)");  if (std::tr2::sys::exists(myfile)) {         std::cout << R"(exists path D:\胡军军\TestStatu.xm)"<<std::endl;

}


2.复制文件

template<class Path1, class Path2> inline void copy_file( const Path1& Pval1, const Path2& Pval2, copy_option Opt = copy_option::fail_if_exists ); std::tr2::sys::path myfile(R"(D:\胡军军\TestStatu.xml)"); std::tr2::sys::path cpyfile(R"(D:\TestStatu.xml)"); if (std::tr2::sys::exists(myfile)) {    std::tr2::sys::copy_file(myfile, cpyfile);    std::cout << R"(exists path D:\胡军军\TestStatu.xml)"<<std::endl; }  


3.创建多级目录(父目录不存在)

template<class Path> inline bool create_directories( const Path& Pval ); std::tr2::sys::path myfile(R"(D:\hehe\haha\)"); if (!std::tr2::sys::exists(myfile)) {    std::tr2::sys::create_directories(myfile); }


4.创建单目录(父目录已经存在)

template<class Path> inline bool create_directory( const Path& Pval ); std::tr2::sys::path myfile(R"(D:\hehe\haha\)"); if (!std::tr2::sys::exists(myfile)    && std::tr2::sys::is_directory(myfile)) {    std::tr2::sys::create_directory(myfile); }


5.其它函数:

template<class Path1, class Path2>
inline bool rename(
   const Path1& Pval1,
   const Path2& Pval2
);

template<class Path>
inline bool remove(
   const Path& Pval
);


template<class Path>
inline unsigned long remove_all(
   const Path& Pval
);


template<class Path>
inline bool remove_directory(
   const Path& Pval
);


template<class Path>
inline bool remove_filename(
   const Path& Pval
);




版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/234272.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Mysql命令_MySQL alter

    Mysql命令_MySQL alter基于Mysql5.7版本的explain参数详解…Mysql官网相关参数解读一:idSELECT标识符1.id越大越先执行2.相同id,从从往下执行二:select_type1.SIMPLE:最简单的查询(没有关联查询没有子查询没有union的查询语句)2:PRIMARY:子查询最外层的查询语句3.SUBQUERY:子查询内层查询语句4.DERIVED:派生表查询,FROM后的不是表而是查询后的结果集5.UNION:union或unionall中的第二个以后的查询表6.U

    2025年12月3日
    1
  • 操作系统栈溢出检測之ucosII篇

    操作系统栈溢出检測之ucosII篇

    2022年1月25日
    40
  • HDU-1387-Team Queue

    HDU-1387-Team Queue

    2022年1月5日
    47
  • Pycharm更换pip默认安装源为国内安装源

    Pycharm更换pip默认安装源为国内安装源1、背景:Python里的pip是官方自带的源,国内使用pip安装的时候十分缓慢,所以最好是更换成中国国内的源地址。2、国内pip源清华:https://pypi.tuna.tsinghua.edu.cn/simple/豆瓣:http://pypi.douban.com/simple/阿里:http://mirrors.aliyun.com/pypi/simple/3、具体操作:在pychram中,依次点击“file”–>”setting”依次点击下.

    2022年8月28日
    5
  • java集合系列——List集合之Vector介绍(四)

    Vector 类可以实现可增长的对象数组。与数组一样,它包含可以使用整数索引进行访问的组件。但是,Vector 的大小可以根据需要增大或缩小,以适应创建 Vector 后进行添加或移除项的操作。Vector 是同步的,可用于多线程。

    2022年2月26日
    43
  • “undefined reference to“ 问题汇总及解决方法 ——非常非常好的一篇文章

    “undefined reference to“ 问题汇总及解决方法 ——非常非常好的一篇文章转载地址:https://segmentfault.com/a/1190000006049907?utm_source=tuicool&utm_medium=referral在实际编译代码的过程中,我们经常会遇到”undefinedreferenceto”的问题,简单的可以轻易地解决,但有些却隐藏得很深,需要花费大量的时间去排查。工作中遇到了各色各样类似的问题,按照以下几

    2022年5月31日
    99

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号