Boost.Filesystem和C ++标准文件系统库有何相似之处? [英] How similar are Boost.Filesystem and the C++ standard filesystem library?
问题描述
我需要一个文件系统库,以供具有C ++ 11功能的编译器或具有C ++ 14功能的编译器使用-因此它不能来自C ++ 17。
I need a filesystem library for use with a C++11-capable compiler or a C++14-capable one - so it can't be be from C++17.
现在,我知道进入C ++ 17的文件系统库基于Boost :: Filesystem;但是-它们是否足够相似,让我可以使用Boost库,然后在以后的时间无缝切换到标准版本,而无需更改超过 using
语句?还是两者之间有(轻微/重大)差异?我知道,对于 variant
而言,Boost和标准库版本存在很大差异。
Now, I know that the filesystem library going into C++17 is based based on Boost::Filesystem; but - are they similar enough for me to use the Boost library and then seamlessly switch to the standard version at a later time, without changing more than, say, a using
statement? Or are there (minor/significant) differences between the two? I know that for the case of variant
, the Boost and the standard library versions differ quite a bit.
推荐答案
有很多区别。我相信其中一些是从未传播的Boost更改。例如,没有 path.filename_is_dot()
查询(如下所述,它在 std :: filesystem $ c中用处不大) $ c>)。
There are a number of differences. Some were, I believe, Boost changes that were never propagated. For example, there is no path.filename_is_dot()
query (as discussed below, it would be less useful in std::filesystem
anyway).
在这方面也有很多最新新闻:
There was also a good bit of late-breaking news on this front:
- 支持非-POSIX式的档案系统:
- 指定字串是OS原生还是POSIX式(或让实现决定,仍然是默认设置)
- 实现可以定义其他文件类型(常规,目录,套接字,等之外)
- 实现可以为目录或设备文件定义
file_size
- Support for non-POSIX-like filesystems:
- Specify whether a string is OS-native or POSIX-like (or let the implementation decide, which is (still) the default)
- An implementation may define additional file types (beyond regular, directory, socket, etc.)
- An implementation may define
file_size
for a directory or device file
-
path( foo /。)。lexically_normal()== foo /
(在Boost中是相反的) -
path( foo /)。filename()==
(是path( 。)
in Boost) -
remove_filename()
留下斜线,因此是幂等(它会在Boost中分配parent_path()
-
path(。profile)。extension()= =
(在Boost中是全名) -
path
分解和组合可以保留诸如通常不可见的备用数据流名称 -
path( foo)/ / bar == / bar
(是path( foo / bar)
(在Boost中),它允许与其他文件(相对或相对)组成相对文件名,并替换Boost的absolute()
- Boost的
system_complete()
(仅接受一个参数)重命名为absolut e()
-
canonical()
因此只接受一个参数(在 DR ) -
lexically_relative()
正确处理..
和根元素 -
permissions()
接受更多参数(Boost将它们合并为位掩码)
path("foo/.").lexically_normal()=="foo/"
(is the opposite in Boost)path("foo/").filename()==""
(ispath(".")
in Boost)remove_filename()
leaves the trailing slash and is thus idempotent (it assignsparent_path()
in Boost)path(".profile").extension()==""
(is the whole name in Boost)path
decompositions and combinations can preserve things like alternate data stream names that are normally invisiblepath("foo")/"/bar"=="/bar"
(ispath("foo/bar")
in Boost), which allows composing relative file names with others (absolute or relative) and replaces Boost'sabsolute()
- Boost's
system_complete()
(which takes only one argument) is renamed toabsolute()
canonical()
thus takes only one argument (fixed in a DR)lexically_relative()
handles..
and root elements correctlypermissions()
takes more arguments (Boost combines them into a bitmask)
请注意,Boost.Filesystem v4在开发中 / a>,并且应该与C ++ 17兼容(但因此在许多方面与v3不兼容)。
Note that Boost.Filesystem v4 is under development and is supposed to be C++17-compatible (but therefore incompatible in many respects with v3).
这篇关于Boost.Filesystem和C ++标准文件系统库有何相似之处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!