
This patch implements the <filesystem> header and uses that to provide <experimental/filesystem>. Unlike other standard headers, the symbols needed for <filesystem> have not yet been placed in libc++.so. Instead they live in the new libc++fs.a library. Users of filesystem are required to link this library. (Also note that libc++experimental no longer contains the definition of <experimental/filesystem>, which now requires linking libc++fs). The reason for keeping <filesystem> out of the dylib for now is that it's still somewhat experimental, and the possibility of requiring an ABI breaking change is very real. In the future the symbols will likely be moved into the dylib, or the dylib will be made to link libc++fs automagically). Note that moving the symbols out of libc++experimental may break user builds until they update to -lc++fs. This should be OK, because the experimental library provides no stability guarantees. However, I plan on looking into ways we can force libc++experimental to automagically link libc++fs. In order to use a single implementation and set of tests for <filesystem>, it has been placed in a special `__fs` namespace. This namespace is inline in C++17 onward, but not before that. As such implementation is available in C++11 onward, but no filesystem namespace is present "directly", and as such name conflicts shouldn't occur in C++11 or C++14. llvm-svn: 338093
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// UNSUPPORTED: c++98, c++03
|
|
|
|
// <filesystem>
|
|
|
|
// class file_status
|
|
|
|
// file_type type() const noexcept;
|
|
// perms permissions(p) const noexcept;
|
|
|
|
#include "filesystem_include.hpp"
|
|
#include <type_traits>
|
|
#include <cassert>
|
|
|
|
|
|
int main() {
|
|
using namespace fs;
|
|
|
|
const file_status st(file_type::regular, perms::owner_read);
|
|
|
|
// type test
|
|
{
|
|
static_assert(noexcept(st.type()),
|
|
"operation must be noexcept");
|
|
static_assert(std::is_same<decltype(st.type()), file_type>::value,
|
|
"operation must return file_type");
|
|
assert(st.type() == file_type::regular);
|
|
}
|
|
// permissions test
|
|
{
|
|
static_assert(noexcept(st.permissions()),
|
|
"operation must be noexcept");
|
|
static_assert(std::is_same<decltype(st.permissions()), perms>::value,
|
|
"operation must return perms");
|
|
assert(st.permissions() == perms::owner_read);
|
|
}
|
|
}
|