mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
Covering filesystem completed
This commit is contained in:
parent
ad79a605b3
commit
59c6330bd3
12 changed files with 87 additions and 47 deletions
|
@ -1,13 +1,16 @@
|
|||
10.9.0 ISN
|
||||
C++-annotations (10.9.0)
|
||||
|
||||
* Added extensive coverage of system_error (Chapters Exception, Advance
|
||||
* Added extensive coverage of system_error (chapters Exception, and Advanced
|
||||
Templates).
|
||||
|
||||
* Added the constructor expecting an initializer-list to the chapter
|
||||
covering the std::string class (chapter 5).
|
||||
* Covered the namespace std::(experimental::)filesystem
|
||||
|
||||
* Added the constructor expecting an initializer-list to the
|
||||
std::string chapter (chapter 5).
|
||||
|
||||
* Explicit references to the C++17 standard were removed.
|
||||
|
||||
|
||||
-- Frank B. Brokken <f.b.brokken@rug.nl> Mon, 04 Dec 2017 17:22:06 +0100
|
||||
|
||||
C++-annotations (10.8.1)
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ sect(Template Meta Programming)
|
|||
lsect(UDL)(User-defined literals)
|
||||
includefile(advancedtemplates/userdefined)
|
||||
|
||||
|
||||
lsect(TEMPTEMPPAR)(Template template parameters)
|
||||
includefile(advancedtemplates/templateparam)
|
||||
|
||||
|
|
|
@ -90,11 +90,12 @@ includefile(concrete/binop)
|
|||
COMMENT(
|
||||
subsect(Binary operators allowing promotions)
|
||||
includefile(concrete/promotions)
|
||||
END)
|
||||
|
||||
lsect(RANGER)(Range-based for-loops and pointer-ranges)
|
||||
includefile(concrete/ranger)
|
||||
|
||||
END)
|
||||
|
||||
lsect(PROXY)(Distinguishing lvalues from rvalues with operator[]())
|
||||
includefile(concrete/proxy)
|
||||
|
||||
|
|
|
@ -205,15 +205,8 @@ includefile(stl/filesystem/intro)
|
|||
system entries: file_status)
|
||||
includefile(stl/filesystem/filestatus)
|
||||
|
||||
COMMENT( TODO
|
||||
subsect(Information about the space of a file system entries: space_info)
|
||||
includefile(stl/filesystem/spaceinfo)
|
||||
END)
|
||||
|
||||
lsubsect(FSFUNCTIONS)(Free functions)
|
||||
includefile(stl/filesystem/functions)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ operators it defines a constructor expecting a tt(path):
|
|||
ithtq(status)(file_status status([error_code &ec]))
|
||||
(returns type and attributes of the current path name. If the current
|
||||
path name refers to a symlink, and the symlink's type and status is
|
||||
required, then use ti(symlink_status) (see also section ref(FSSTATUS)).
|
||||
required, then use ti(symlink_status) (see also section
|
||||
ref(FSSTATUS))).
|
||||
)
|
||||
|
||||
Also, tt(directory_entry) objects may be compared using the tt(==, !=, <, <=,
|
||||
|
|
|
@ -19,11 +19,11 @@ try
|
|||
}
|
||||
catch (fs::filesystem_error const &fse)
|
||||
{
|
||||
cerr << fse.what() << ",\n" <<
|
||||
cerr << fse.what() << ",\n" <<
|
||||
fse.path1() << ",\n" <<
|
||||
fse.path2() << ",\n" <<
|
||||
fse.path2() << ",\n" <<
|
||||
fse.code() << '\n';
|
||||
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
23
annotations/yo/stl/filesystem/examples/spaceinfo.cc
Normal file
23
annotations/yo/stl/filesystem/examples/spaceinfo.cc
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <iostream>
|
||||
#include <experimental/filesystem>
|
||||
|
||||
// explicitly link against stdc++fs:
|
||||
//
|
||||
// gx spaceinfo.cc -lstdc++fs
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
//demo
|
||||
int main()
|
||||
{
|
||||
fs::path p{ "/tmp" };
|
||||
|
||||
auto pod = fs::space(p);
|
||||
|
||||
std::cout << "The filesystem containing /tmp has a capacity of " <<
|
||||
pod.capacity << " bytes,\n"
|
||||
"i.e., " << pod.capacity / 1024 << " KB.\n"
|
||||
"# free bytes: " << pod.free << "\n"
|
||||
"# available: " << pod.available << '\n';
|
||||
}
|
||||
//=
|
|
@ -30,7 +30,7 @@ namespace
|
|||
void status(fs::path const &path)
|
||||
{
|
||||
fs::file_status stat = fs::directory_entry{ path }.symlink_status();
|
||||
|
||||
|
||||
cout << path << " is " << map[stat.type()] << '\n';
|
||||
};
|
||||
} // anon. namespace
|
||||
|
@ -44,11 +44,3 @@ int main()
|
|||
status_known( fs::file_status{} ) << '\n';
|
||||
}
|
||||
//=
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
The tt(experimental/filesystem) namespace offers its own exception type
|
||||
ti(filesystem_error). Its constructors have the following signatures (the
|
||||
The tt(std::(experimental::)filesystem) namespace offers its own exception
|
||||
type ti(filesystem_error). Its constructors have the following signatures (the
|
||||
bracketed parameters are optional):
|
||||
verb(
|
||||
filesystem_error(string const &what,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
Several system calls are usually available in the context of the bf(C)
|
||||
programming language. Such function (like bf(rename)(2), tt(truncate)(2),
|
||||
bf(opendir)(2), and bf(realpath)(3)) are of course also available in bf(C++),
|
||||
|
@ -11,21 +10,21 @@ url(Boost library)
|
|||
(http://www.boost.org/doc/libs/1_65_1/libs/filesystem/doc/index.htm)
|
||||
hi(Boost Filesystem)
|
||||
Currently, bf(C++) directly supports these facilities in the
|
||||
tt(std::experimental::filesystem)hi(experimental::filesystem)hi(filesystem)
|
||||
tt(std::(experimental::)filesystem)hi(experimental::filesystem)hi(filesystem)
|
||||
namespace. To use these facilities the
|
||||
hi(experimental/filesystem) header file must be included. In addition,
|
||||
programs using facilities from the tt(experimental::filesystem) namespace must
|
||||
be linked against the hi(stdc++fs library)tt(stdc++fs) library:
|
||||
programs using facilities from the tt(std::(experimental::)filesystem)
|
||||
namespace must be linked against the hi(stdc++fs library)tt(stdc++fs) library:
|
||||
tt(-lstdc++fs).
|
||||
|
||||
Although tt(filesystem) currently is nested under the tt(experimental)
|
||||
namespace, all facilities are available, and it's likely that in due time
|
||||
`experimental' in front of tt(filesystem) will be dropped.
|
||||
Although the tt(filesystem) namespace currently is nested under the
|
||||
tt(experimental) namespace, all facilities are available, and it's likely that
|
||||
in due time `experimental' in front of tt(filesystem) will be dropped.
|
||||
|
||||
The tt(experimental/filesystem) namespace is extensive: it offers more than 10
|
||||
different classes, and over 30 different free functions.
|
||||
The tt(filesystem) namespace is extensive: it offers more
|
||||
than 10 different classes, and over 30 different free functions.
|
||||
|
||||
In this and subsequent subsections the notation tt(fs::) is used to refer to
|
||||
the tt(std::experimental::filesystem) namespace.
|
||||
the namespace tt(std::(experimental::)filesystem).
|
||||
|
||||
|
||||
|
|
23
annotations/yo/stl/filesystem/spaceinfo.yo
Normal file
23
annotations/yo/stl/filesystem/spaceinfo.yo
Normal file
|
@ -0,0 +1,23 @@
|
|||
Every existing tt(path) lives in a particular file system. File systems can
|
||||
contain certain amounts of data (numbers of bytes) of which some amount
|
||||
already is in use and some amount is still available. These three pieces of
|
||||
information are made available by the function
|
||||
tt(fs::space)hi(space(_info))hi(available space) expecting a tt(fs::path
|
||||
const &), and returning the information in a POD tt(struct fs::space_info).
|
||||
This function throws a tt(filesystem_error), receiving tt(path) as its first
|
||||
argument and the operating system's error code as its tt(error_code)
|
||||
argument. An overloaded function tt(space) expects as its second argument an
|
||||
tt(error_code) object, which is cleared if no error occurs, and which is set
|
||||
to the operating system's error code if an error occurred.
|
||||
|
||||
The returned tt(fs::space_info) has three fields:
|
||||
verb(
|
||||
uintmax_t capacity; // total size in bytes
|
||||
uintmax_t free; // number of free bytes on the file system
|
||||
uintmax_t available; // free bytes for a non-privileged process
|
||||
)
|
||||
If a field cannot be determined it is set to -1 (i.e., the max. value of
|
||||
the type tt(uintmax_t)).
|
||||
|
||||
Here is a little program illustrating how tt(space) can be used:
|
||||
verbinsert(-s4 //demo examples/spaceinfo.cc)
|
|
@ -9,14 +9,20 @@ COMMENT(
|
|||
standard also adds em(fold expressions)to the language: covered in
|
||||
a sub-section of section ref(VARIADIC).
|
||||
END)
|
||||
it() In version 10.9.0, since the C++17 standard has by now been implemented
|
||||
by Gnu's tt(g++) compiler, explicit references to that standard were
|
||||
removed. Also, sections covering topics that are no longer supported
|
||||
in C++17 (e.g. covering tt(ptr_fun) and tt(random_shuffle)) were
|
||||
removed. Coverage of lambda expressions was moved from the `STL'
|
||||
chapter to the `Operator Overloading' chapter: lambda expressions are
|
||||
compiled by the compiler using standard syntactic rules, and are not
|
||||
predefined templates, as provided by the STL.
|
||||
it() In version 10.9.0, since the C++17 standard has by now been
|
||||
implemented by Gnu's tt(g++) compiler, explicit references to that
|
||||
standard were removed. Also, sections covering topics that are no
|
||||
longer supported in C++17 (like tt(ptr_fun) and tt(random_shuffle))
|
||||
were removed. Lambda expressions are now covered in chapter about
|
||||
`Operator Overloading' (chapter ref(OVERLOADING)): lambda expressions
|
||||
are compiled by the compiler using standard syntactic rules, and are
|
||||
not predefined templates, as provided by the STL. The sections about
|
||||
tt(std::system_error) (and friends) were rewritten, and were split
|
||||
into sections introducing their facilities (chapter ref(EXCEPTIONS))
|
||||
and sections describing how classes can be designed that are accepted
|
||||
by tt(system_error) (chapter ref(ADVANCEDTEMPL)). The chapter about
|
||||
the STL (chapter ref(STL)) now contains sections covering the
|
||||
tt(std::(experimental::)filesystem) namespace.
|
||||
it() Version 10.8.0 contains a new section providing an
|
||||
overview of new language features introduced by the C++17 standard,
|
||||
and many typos and suboptimally formulated statements were fixed.
|
||||
|
|
Loading…
Reference in a new issue