Commit 0ca7ba9a by Jonathan Wakely Committed by Jonathan Wakely

Implement N4100 File System TS

	* acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Define.
	(GLIBCXX_CHECK_FILESYSTEM_DEPS): Define.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Enable filesystem TS and check its dependencies.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/bits/locale_conv.h (__do_str_code_cvt, __str_codecvt_in,
	__str_codecvt_out): Move code conversion logic from wstring_convert
	into new global functions.
	(wstring_convert::to_bytes, wstring_convert::from_bytes): Use new
	functions.
	(wstring_convert::_M_conv): Remove.
	* include/bits/quoted_string.h (_Quoted_string): Split out of iomanip.
	* include/experimental/filesystem: New.
	* include/experimental/fs_dir.h: New.
	* include/experimental/fs_fwd.h: New.
	* include/experimental/fs_ops.h: New.
	* include/experimental/fs_path.h: New.
	* include/std/iomanip (_Quoted_string): Move to bits/quoted_string.h.
	* python/libstdcxx/v6/printers.py (StdExpPathPrinter): Add.
	* src/Makefile.am (SUBDIRS): Add filesystem.
	* src/Makefile.in: Regenerate.
	* src/filesystem/Makefile.am: New.
	* src/filesystem/Makefile.in: New.
	* src/filesystem/dir.cc: New.
	* src/filesystem/ops.cc: New.
	* src/filesystem/path.cc: New.
	* testsuite/experimental/filesystem/operations/absolute.cc: New.
	* testsuite/experimental/filesystem/operations/copy.cc: New.
	* testsuite/experimental/filesystem/operations/current_path.cc: New.
	* testsuite/experimental/filesystem/path/append/path.cc: New.
	* testsuite/experimental/filesystem/path/assign/assign.cc: New.
	* testsuite/experimental/filesystem/path/assign/copy.cc: New.
	* testsuite/experimental/filesystem/path/compare/compare.cc: New.
	* testsuite/experimental/filesystem/path/compare/path.cc: New.
	* testsuite/experimental/filesystem/path/compare/strings.cc: New.
	* testsuite/experimental/filesystem/path/concat/path.cc: New.
	* testsuite/experimental/filesystem/path/concat/strings.cc: New.
	* testsuite/experimental/filesystem/path/construct/copy.cc: New.
	* testsuite/experimental/filesystem/path/construct/default.cc: New.
	* testsuite/experimental/filesystem/path/construct/locale.cc: New.
	* testsuite/experimental/filesystem/path/construct/range.cc: New.
	* testsuite/experimental/filesystem/path/decompose/extension.cc: New.
	* testsuite/experimental/filesystem/path/decompose/filename.cc: New.
	* testsuite/experimental/filesystem/path/decompose/parent_path.cc:
	New.
	* testsuite/experimental/filesystem/path/decompose/relative_path.cc:
	New.
	* testsuite/experimental/filesystem/path/decompose/root_directory.cc:
	New.
	* testsuite/experimental/filesystem/path/decompose/root_name.cc:
	New.
	* testsuite/experimental/filesystem/path/decompose/root_path.cc:
	New.
	* testsuite/experimental/filesystem/path/decompose/stem.cc: New.
	* testsuite/experimental/filesystem/path/generic/generic_string.cc:
	New.
	* testsuite/experimental/filesystem/path/itr/traversal.cc: New.
	* testsuite/experimental/filesystem/path/modifiers/clear.cc: New.
	* testsuite/experimental/filesystem/path/modifiers/make_preferred.cc:
	New.
	* testsuite/experimental/filesystem/path/modifiers/remove_filename.cc:
	New.
	* testsuite/experimental/filesystem/path/modifiers/replace_extension.cc:
	New.
	* testsuite/experimental/filesystem/path/modifiers/replace_filename.cc:
	New.
	* testsuite/experimental/filesystem/path/modifiers/swap.cc: New.
	* testsuite/experimental/filesystem/path/nonmember/hash_value.cc: New.
	* testsuite/experimental/filesystem/path/query/empty.cc: New.
	* testsuite/experimental/filesystem/path/query/has_extension.cc: New.
	* testsuite/experimental/filesystem/path/query/has_filename.cc: New.
	* testsuite/experimental/filesystem/path/query/has_parent_path.cc:
	New.
	* testsuite/experimental/filesystem/path/query/has_relative_path.cc:
	New.
	* testsuite/experimental/filesystem/path/query/has_root_directory.cc:
	New.
	* testsuite/experimental/filesystem/path/query/has_root_name.cc:
	New.
	* testsuite/experimental/filesystem/path/query/has_root_path.cc:
	New.
	* testsuite/experimental/filesystem/path/query/has_stem.cc: New.
	* testsuite/experimental/filesystem/path/query/is_relative.cc: New.
	* testsuite/util/testsuite_fs.h: New.

From-SVN: r222654
parent 59c1f384
2015-04-30 Jonathan Wakely <jwakely@redhat.com>
Implement N4100 File System TS
* acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Define.
(GLIBCXX_CHECK_FILESYSTEM_DEPS): Define.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Enable filesystem TS and check its dependencies.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/bits/locale_conv.h (__do_str_code_cvt, __str_codecvt_in,
__str_codecvt_out): Move code conversion logic from wstring_convert
into new global functions.
(wstring_convert::to_bytes, wstring_convert::from_bytes): Use new
functions.
(wstring_convert::_M_conv): Remove.
* include/bits/quoted_string.h (_Quoted_string): Split out of iomanip.
* include/experimental/filesystem: New.
* include/experimental/fs_dir.h: New.
* include/experimental/fs_fwd.h: New.
* include/experimental/fs_ops.h: New.
* include/experimental/fs_path.h: New.
* include/std/iomanip (_Quoted_string): Move to bits/quoted_string.h.
* python/libstdcxx/v6/printers.py (StdExpPathPrinter): Add.
* src/Makefile.am (SUBDIRS): Add filesystem.
* src/Makefile.in: Regenerate.
* src/filesystem/Makefile.am: New.
* src/filesystem/Makefile.in: New.
* src/filesystem/dir.cc: New.
* src/filesystem/ops.cc: New.
* src/filesystem/path.cc: New.
* testsuite/experimental/filesystem/operations/absolute.cc: New.
* testsuite/experimental/filesystem/operations/copy.cc: New.
* testsuite/experimental/filesystem/operations/current_path.cc: New.
* testsuite/experimental/filesystem/path/append/path.cc: New.
* testsuite/experimental/filesystem/path/assign/assign.cc: New.
* testsuite/experimental/filesystem/path/assign/copy.cc: New.
* testsuite/experimental/filesystem/path/compare/compare.cc: New.
* testsuite/experimental/filesystem/path/compare/path.cc: New.
* testsuite/experimental/filesystem/path/compare/strings.cc: New.
* testsuite/experimental/filesystem/path/concat/path.cc: New.
* testsuite/experimental/filesystem/path/concat/strings.cc: New.
* testsuite/experimental/filesystem/path/construct/copy.cc: New.
* testsuite/experimental/filesystem/path/construct/default.cc: New.
* testsuite/experimental/filesystem/path/construct/locale.cc: New.
* testsuite/experimental/filesystem/path/construct/range.cc: New.
* testsuite/experimental/filesystem/path/decompose/extension.cc: New.
* testsuite/experimental/filesystem/path/decompose/filename.cc: New.
* testsuite/experimental/filesystem/path/decompose/parent_path.cc:
New.
* testsuite/experimental/filesystem/path/decompose/relative_path.cc:
New.
* testsuite/experimental/filesystem/path/decompose/root_directory.cc:
New.
* testsuite/experimental/filesystem/path/decompose/root_name.cc:
New.
* testsuite/experimental/filesystem/path/decompose/root_path.cc:
New.
* testsuite/experimental/filesystem/path/decompose/stem.cc: New.
* testsuite/experimental/filesystem/path/generic/generic_string.cc:
New.
* testsuite/experimental/filesystem/path/itr/traversal.cc: New.
* testsuite/experimental/filesystem/path/modifiers/clear.cc: New.
* testsuite/experimental/filesystem/path/modifiers/make_preferred.cc:
New.
* testsuite/experimental/filesystem/path/modifiers/remove_filename.cc:
New.
* testsuite/experimental/filesystem/path/modifiers/replace_extension.cc:
New.
* testsuite/experimental/filesystem/path/modifiers/replace_filename.cc:
New.
* testsuite/experimental/filesystem/path/modifiers/swap.cc: New.
* testsuite/experimental/filesystem/path/nonmember/hash_value.cc: New.
* testsuite/experimental/filesystem/path/query/empty.cc: New.
* testsuite/experimental/filesystem/path/query/has_extension.cc: New.
* testsuite/experimental/filesystem/path/query/has_filename.cc: New.
* testsuite/experimental/filesystem/path/query/has_parent_path.cc:
New.
* testsuite/experimental/filesystem/path/query/has_relative_path.cc:
New.
* testsuite/experimental/filesystem/path/query/has_root_directory.cc:
New.
* testsuite/experimental/filesystem/path/query/has_root_name.cc:
New.
* testsuite/experimental/filesystem/path/query/has_root_path.cc:
New.
* testsuite/experimental/filesystem/path/query/has_stem.cc: New.
* testsuite/experimental/filesystem/path/query/is_relative.cc: New.
* testsuite/util/testsuite_fs.h: New.
2015-04-30 Edward Smith-Rowland <3dw4rd@verizon.net>
Add fundamentals TR container erasure.
......
......@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
# Keep these sync'd with the list in Makefile.am. The first provides an
# expandable list at autoconf time; the second provides an expandable list
# (i.e., shell variable) at configure time.
m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 doc po testsuite python])
m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/filesystem doc po testsuite python])
SUBDIRS='glibcxx_SUBDIRS'
# These need to be absolute paths, yet at the same time need to
......@@ -3903,6 +3903,99 @@ AC_DEFUN([GLIBCXX_DEFAULT_ABI], [
GLIBCXX_CONDITIONAL(ENABLE_CXX11_ABI, test $glibcxx_cxx11_abi = 1)
])
dnl
dnl Check to see whether to build libstdc++fs.a
dnl
dnl --enable-libstdcxx-filesystem-ts
dnl
AC_DEFUN([GLIBCXX_ENABLE_FILESYSTEM_TS], [
GLIBCXX_ENABLE(libstdcxx-filesystem-ts,auto,,
[turns on ISO/IEC TS 18822 support],
[permit yes|no|auto])
AC_MSG_CHECKING([whether to build Filesystem TS support])
if test x"$enable_libstdcxx_filesystem_ts" = x"auto"; then
case "${target_os}" in
freebsd*|netbsd*|openbsd*|dragonfly*|darwin*)
enable_libstdcxx_filesystem_ts=yes
;;
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
enable_libstdcxx_filesystem_ts=yes
;;
solaris*)
enable_libstdcxx_filesystem_ts=yes
;;
*)
enable_libstdcxx_filesystem_ts=no
;;
esac
fi
AC_MSG_RESULT($enable_libstdcxx_filesystem_ts)
GLIBCXX_CONDITIONAL(ENABLE_FILESYSTEM_TS, test $enable_libstdcxx_filesystem_ts = yes)
])
dnl
dnl Check whether the library calls required by the Filesystem TS are present
dnl and define _GLIBCXX_USE_REALPATH and _GLIBCXX_USE_UTIMENSAT.
dnl
AC_DEFUN([GLIBCXX_CHECK_FILESYSTEM_DEPS], [dnl
dnl
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fno-exceptions"
dnl
AC_MSG_CHECKING([for realpath])
AC_CACHE_VAL(glibcxx_cv_realpath, [dnl
GCC_TRY_COMPILE_OR_LINK(
[#include <stdlib.h>],
[char *tmp = realpath((const char*)NULL, (char*)NULL);],
[glibcxx_cv_realpath=yes],
[glibcxx_cv_realpath=no])
])
if test $glibcxx_cv_realpath = yes; then
AC_DEFINE(_GLIBCXX_USE_REALPATH, 1, [Define if realpath is available in <stdlib.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_realpath)
dnl
AC_MSG_CHECKING([for utimensat])
AC_CACHE_VAL(glibcxx_cv_utimensat, [dnl
GCC_TRY_COMPILE_OR_LINK(
[
#include <fcntl.h>
#include <sys/stat.h>
],
[
struct timespec ts[2] = { { 0, UTIME_OMIT }, { 1, 1 } };
int i = utimensat(AT_FDCWD, "path", ts, 0);
],
[glibcxx_cv_utimensat=yes],
[glibcxx_cv_utimensat=no])
])
if test $glibcxx_cv_utimensat = yes; then
AC_DEFINE(_GLIBCXX_USE_UTIMENSAT, 1, [Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_utimensat)
dnl
AC_MSG_CHECKING([for struct stat.st_mtim.tv_nsec])
AC_CACHE_VAL(glibcxx_cv_st_mtim, [dnl
GCC_TRY_COMPILE_OR_LINK(
[ #include <sys/stat.h> ],
[
struct stat st;
return st.st_mtim.tv_nsec;
],
[glibcxx_cv_st_mtim=yes],
[glibcxx_cv_st_mtim=no])
])
if test $glibcxx_cv_st_mtim = yes; then
AC_DEFINE(_GLIBCXX_USE_ST_MTIM, 1, [Define if struct stat has timespec members.])
fi
AC_MSG_RESULT($glibcxx_cv_st_mtim)
dnl
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
# Macros from the top-level gcc directory.
m4_include([../config/gc++filt.m4])
......
......@@ -54,6 +54,10 @@
/* Define to 1 if you have the `cosl' function. */
#undef HAVE_COSL
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
......@@ -132,6 +136,9 @@
/* Define to 1 if you have the `fabsl' function. */
#undef HAVE_FABSL
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the <fenv.h> header file. */
#undef HAVE_FENV_H
......@@ -294,6 +301,9 @@
/* Define to 1 if you have the <nan.h> header file. */
#undef HAVE_NAN_H
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define if poll is available in <poll.h>. */
#undef HAVE_POLL
......@@ -372,6 +382,9 @@
/* Define to 1 if you have the `strtold' function. */
#undef HAVE_STRTOLD
/* Define to 1 if `struct dirent' is a member of `d_type'. */
#undef HAVE_STRUCT_DIRENT_D_TYPE
/* Define if strxfrm_l is available in <string.h>. */
#undef HAVE_STRXFRM_L
......@@ -379,6 +392,10 @@
to different versions. */
#undef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/filio.h> header file. */
#undef HAVE_SYS_FILIO_H
......@@ -394,6 +411,10 @@
/* Define to 1 if you have the <sys/machine.h> header file. */
#undef HAVE_SYS_MACHINE_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
......@@ -406,6 +427,9 @@
/* Define to 1 if you have the <sys/sem.h> header file. */
#undef HAVE_SYS_SEM_H
/* Define to 1 if you have the <sys/statvfs.h> header file. */
#undef HAVE_SYS_STATVFS_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
......@@ -858,6 +882,9 @@
of TR1 (Chapter 5.1). */
#undef _GLIBCXX_USE_RANDOM_TR1
/* Define if realpath is available in <stdlib.h>. */
#undef _GLIBCXX_USE_REALPATH
/* Defined if sched_yield is available. */
#undef _GLIBCXX_USE_SCHED_YIELD
......@@ -867,12 +894,19 @@
/* Define if _SC_NPROC_ONLN is available in <unistd.h>. */
#undef _GLIBCXX_USE_SC_NPROC_ONLN
/* Define if struct stat has timespec members. */
#undef _GLIBCXX_USE_ST_MTIM
/* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */
#undef _GLIBCXX_USE_SYSCTL_HW_NCPU
/* Define if obsolescent tmpnam is available in <stdio.h>. */
#undef _GLIBCXX_USE_TMPNAM
/* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and
AT_FDCWD in <fcntl.h>. */
#undef _GLIBCXX_USE_UTIMENSAT
/* Define if code specialized for wchar_t should be used. */
#undef _GLIBCXX_USE_WCHAR_T
......
......@@ -402,6 +402,12 @@ GLIBCXX_CONFIGURE_TESTSUITE
# For gthread support. Depends on GLIBCXX_ENABLE_SYMVERS.
GLIBCXX_CHECK_GTHREADS
# For Filesystem TS.
AC_CHECK_HEADERS([fcntl.h dirent.h sys/statvfs.h])
AC_STRUCT_DIRENT_D_TYPE
GLIBCXX_ENABLE_FILESYSTEM_TS
GLIBCXX_CHECK_FILESYSTEM_DEPS
# Define documentation rules conditionally.
# See if makeinfo has been installed and is modern enough
......
......@@ -128,6 +128,7 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/predefined_ops.h \
${bits_srcdir}/ptr_traits.h \
${bits_srcdir}/quoted_string.h \
${bits_srcdir}/random.h \
${bits_srcdir}/random.tcc \
${bits_srcdir}/range_access.h \
......@@ -663,7 +664,19 @@ experimental_headers = \
${experimental_srcdir}/type_traits \
${experimental_srcdir}/unordered_map \
${experimental_srcdir}/unordered_set \
${experimental_srcdir}/vector
${experimental_srcdir}/vector \
${experimental_filesystem_headers}
if ENABLE_FILESYSTEM_TS
experimental_filesystem_headers = \
${experimental_srcdir}/filesystem \
${experimental_srcdir}/fs_dir.h \
${experimental_srcdir}/fs_fwd.h \
${experimental_srcdir}/fs_ops.h \
${experimental_srcdir}/fs_path.h
else
experimental_filesystem_headers =
endif
# This is the common subset of C++ files that all three "C" header models use.
c_base_srcdir = $(C_INCLUDE_DIR)
......
......@@ -396,6 +396,7 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/predefined_ops.h \
${bits_srcdir}/ptr_traits.h \
${bits_srcdir}/quoted_string.h \
${bits_srcdir}/random.h \
${bits_srcdir}/random.tcc \
${bits_srcdir}/range_access.h \
......@@ -930,7 +931,16 @@ experimental_headers = \
${experimental_srcdir}/type_traits \
${experimental_srcdir}/unordered_map \
${experimental_srcdir}/unordered_set \
${experimental_srcdir}/vector
${experimental_srcdir}/vector \
${experimental_filesystem_headers}
@ENABLE_FILESYSTEM_TS_FALSE@experimental_filesystem_headers =
@ENABLE_FILESYSTEM_TS_TRUE@experimental_filesystem_headers = \
@ENABLE_FILESYSTEM_TS_TRUE@ ${experimental_srcdir}/filesystem \
@ENABLE_FILESYSTEM_TS_TRUE@ ${experimental_srcdir}/fs_dir.h \
@ENABLE_FILESYSTEM_TS_TRUE@ ${experimental_srcdir}/fs_fwd.h \
@ENABLE_FILESYSTEM_TS_TRUE@ ${experimental_srcdir}/fs_ops.h \
@ENABLE_FILESYSTEM_TS_TRUE@ ${experimental_srcdir}/fs_path.h
# This is the common subset of C++ files that all three "C" header models use.
......
......@@ -51,6 +51,105 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/
template<typename _OutStr, typename _InChar, typename _Codecvt,
typename _State, typename _Fn>
bool
__do_str_codecvt(const _InChar* __first, const _InChar* __last,
_OutStr& __outstr, const _Codecvt& __cvt, _State& __state,
size_t& __count, _Fn __fn)
{
size_t __outchars = 0;
auto __next = __first;
const auto __maxlen = __cvt.max_length();
codecvt_base::result __result;
do
{
__outstr.resize(__outstr.size() + (__last - __next) + __maxlen);
auto __outnext = &__outstr.front() + __outchars;
auto const __outlast = &__outstr.back() + 1;
__result = (__cvt.*__fn)(__state, __next, __last, __next,
__outnext, __outlast, __outnext);
__outchars = __outnext - &__outstr.front();
}
while (__result == codecvt_base::partial && __next != __last
&& (__outstr.size() - __outchars) < __maxlen);
if (__result == codecvt_base::error)
return false;
if (__result == codecvt_base::noconv)
{
__outstr.assign(__first, __last);
__count = __last - __first;
}
else
{
__outstr.resize(__outchars);
__count = __next - __first;
}
return true;
}
// Convert narrow character string to wide.
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
inline bool
__str_codecvt_in(const char* __first, const char* __last,
basic_string<_CharT, _Traits, _Alloc>& __outstr,
const codecvt<_CharT, char, _State>& __cvt,
_State& __state, size_t& __count)
{
using _Codecvt = codecvt<_CharT, char, _State>;
using _ConvFn
= codecvt_base::result
(_Codecvt::*)(_State&, const char*, const char*, const char*&,
_CharT*, _CharT*, _CharT*&) const;
_ConvFn __fn = &codecvt<_CharT, char, _State>::in;
return __do_str_codecvt(__first, __last, __outstr, __cvt, __state,
__count, __fn);
}
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
inline bool
__str_codecvt_in(const char* __first, const char* __last,
basic_string<_CharT, _Traits, _Alloc>& __outstr,
const codecvt<_CharT, char, _State>& __cvt)
{
_State __state = {};
size_t __n;
return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n);
}
// Convert wide character string to narrow.
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
inline bool
__str_codecvt_out(const _CharT* __first, const _CharT* __last,
basic_string<char, _Traits, _Alloc>& __outstr,
const codecvt<_CharT, char, _State>& __cvt,
_State& __state, size_t& __count)
{
using _Codecvt = codecvt<_CharT, char, _State>;
using _ConvFn
= codecvt_base::result
(_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&,
char*, char*, char*&) const;
_ConvFn __fn = &codecvt<_CharT, char, _State>::out;
return __do_str_codecvt(__first, __last, __outstr, __cvt, __state,
__count, __fn);
}
template<typename _CharT, typename _Traits, typename _Alloc, typename _State>
inline bool
__str_codecvt_out(const _CharT* __first, const _CharT* __last,
basic_string<char, _Traits, _Alloc>& __outstr,
const codecvt<_CharT, char, _State>& __cvt)
{
_State __state = {};
size_t __n;
return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n);
}
/// String conversions
template<typename _Codecvt, typename _Elem = wchar_t,
typename _Wide_alloc = allocator<_Elem>,
......@@ -136,9 +235,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
wide_string
from_bytes(const char* __first, const char* __last)
{
auto __errstr = _M_with_strings ? &_M_wide_err_string : nullptr;
_ConvFn<char, _Elem> __fn = &_Codecvt::in;
return _M_conv(__first, __last, __errstr, __fn);
if (!_M_with_cvtstate)
_M_state = state_type();
wide_string __out{ _M_wide_err_string.get_allocator() };
if (__str_codecvt_in(__first, __last, __out, *_M_cvt, _M_state,
_M_count))
return __out;
if (_M_with_strings)
return _M_wide_err_string;
__throw_range_error("wstring_convert::from_bytes");
}
/// @}
......@@ -166,9 +271,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
byte_string
to_bytes(const _Elem* __first, const _Elem* __last)
{
auto __errstr = _M_with_strings ? &_M_byte_err_string : nullptr;
_ConvFn<_Elem, char> __fn = &_Codecvt::out;
return _M_conv(__first, __last, __errstr, __fn);
if (!_M_with_cvtstate)
_M_state = state_type();
byte_string __out{ _M_byte_err_string.get_allocator() };
if (__str_codecvt_out(__first, __last, __out, *_M_cvt, _M_state,
_M_count))
return __out;
if (_M_with_strings)
return _M_byte_err_string;
__throw_range_error("wstring_convert::to_bytes");
}
/// @}
......@@ -181,56 +292,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
state_type state() const { return _M_state; }
private:
template<typename _InC, typename _OutC>
using _ConvFn
= codecvt_base::result
(_Codecvt::*)(state_type&, const _InC*, const _InC*, const _InC*&,
_OutC*, _OutC*, _OutC*&) const;
template<typename _InChar, typename _OutStr, typename _MemFn>
_OutStr
_M_conv(const _InChar* __first, const _InChar* __last,
const _OutStr* __err, _MemFn __memfn)
{
if (!_M_with_cvtstate)
_M_state = state_type();
auto __outstr = __err ? _OutStr(__err->get_allocator()) : _OutStr();
size_t __outchars = 0;
auto __next = __first;
const auto __maxlen = _M_cvt->max_length();
codecvt_base::result __result;
do
{
__outstr.resize(__outstr.size() + (__last - __next) + __maxlen);
auto __outnext = &__outstr.front() + __outchars;
auto const __outlast = &__outstr.back() + 1;
__result = ((*_M_cvt).*__memfn)(_M_state, __next, __last, __next,
__outnext, __outlast, __outnext);
__outchars = __outnext - &__outstr.front();
}
while (__result == codecvt_base::partial && __next != __last
&& (__outstr.size() - __outchars) < __maxlen);
if (__result == codecvt_base::noconv)
{
__outstr.assign(__first, __last);
_M_count = __outstr.size();
return __outstr;
}
__outstr.resize(__outchars);
_M_count = __next - __first;
if (__result != codecvt_base::error)
return __outstr;
else if (__err)
return *__err;
else
__throw_range_error("wstring_convert");
}
unique_ptr<_Codecvt> _M_cvt;
byte_string _M_byte_err_string;
wide_string _M_wide_err_string;
......
// Helpers for quoted stream manipulators -*- C++ -*-
// Copyright (C) 2013-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/quoted_string.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iomanip}
*/
#ifndef _GLIBCXX_QUOTED_STRING_H
#define _GLIBCXX_QUOTED_STRING_H 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <sstream>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __detail {
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Struct for delimited strings.
*/
template<typename _String, typename _CharT>
struct _Quoted_string
{
static_assert(is_reference<_String>::value
|| is_pointer<_String>::value,
"String type must be pointer or reference");
_Quoted_string(_String __str, _CharT __del, _CharT __esc)
: _M_string(__str), _M_delim{__del}, _M_escape{__esc}
{ }
_Quoted_string&
operator=(_Quoted_string&) = delete;
_String _M_string;
_CharT _M_delim;
_CharT _M_escape;
};
/**
* @brief Inserter for quoted strings.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 2344 quoted()'s interaction with padding is unclear
*/
template<typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const _Quoted_string<const _CharT*, _CharT>& __str)
{
std::basic_ostringstream<_CharT, _Traits> __ostr;
__ostr << __str._M_delim;
for (const _CharT* __c = __str._M_string; *__c; ++__c)
{
if (*__c == __str._M_delim || *__c == __str._M_escape)
__ostr << __str._M_escape;
__ostr << *__c;
}
__ostr << __str._M_delim;
return __os << __ostr.str();
}
/**
* @brief Inserter for quoted strings.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 2344 quoted()'s interaction with padding is unclear
*/
template<typename _CharT, typename _Traits, typename _String>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const _Quoted_string<_String, _CharT>& __str)
{
std::basic_ostringstream<_CharT, _Traits> __ostr;
__ostr << __str._M_delim;
for (auto& __c : __str._M_string)
{
if (__c == __str._M_delim || __c == __str._M_escape)
__ostr << __str._M_escape;
__ostr << __c;
}
__ostr << __str._M_delim;
return __os << __ostr.str();
}
/**
* @brief Extractor for delimited strings.
* The left and right delimiters can be different.
*/
template<typename _CharT, typename _Traits, typename _Alloc>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
const _Quoted_string<basic_string<_CharT, _Traits, _Alloc>&,
_CharT>& __str)
{
_CharT __c;
__is >> __c;
if (!__is.good())
return __is;
if (__c != __str._M_delim)
{
__is.unget();
__is >> __str._M_string;
return __is;
}
__str._M_string.clear();
std::ios_base::fmtflags __flags
= __is.flags(__is.flags() & ~std::ios_base::skipws);
do
{
__is >> __c;
if (!__is.good())
break;
if (__c == __str._M_escape)
{
__is >> __c;
if (!__is.good())
break;
}
else if (__c == __str._M_delim)
break;
__str._M_string += __c;
}
while (true);
__is.setf(__flags);
return __is;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail
} // namespace std
#endif // C++11
#endif /* _GLIBCXX_QUOTED_STRING_H */
// <experimental/filesystem> -*- C++ -*-
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file experimental/filesystem
* This is a TS C++ Library header.
*/
#ifndef _GLIBCXX_EXPERIMENTAL_FILESYSTEM
#define _GLIBCXX_EXPERIMENTAL_FILESYSTEM 1
#pragma GCC system_header
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <experimental/fs_fwd.h>
#include <experimental/fs_path.h>
#include <experimental/fs_dir.h>
#include <experimental/fs_ops.h>
#define __cpp_lib_experimental_filesystem 201406
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace experimental
{
namespace filesystem
{
inline namespace v1
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @ingroup filesystem
*/
inline std::string filesystem_error::_M_gen_what()
{
std::string __what = "filesystem error: ";
__what += system_error::what();
if (!_M_path1.empty())
__what += " [" + _M_path1.string() + ']';
if (!_M_path2.empty())
__what += " [" + _M_path2.string() + ']';
return __what;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace v1
} // namespace filesystem
} // namespace experimental
} // namespace std
#endif // C++11
#endif // _GLIBCXX_EXPERIMENTAL_FILESYSTEM
// Filesystem declarations -*- C++ -*-
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file experimental/filesystem
* This is a TS C++ Library header.
*/
#ifndef _GLIBCXX_EXPERIMENTAL_FS_FWD_H
#define _GLIBCXX_EXPERIMENTAL_FS_FWD_H 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <system_error>
#include <cstdint>
#include <chrono>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace experimental
{
namespace filesystem
{
inline namespace v1
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_USE_CXX11_ABI
inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
#endif
/**
* @defgroup filesystem
* @ingroup experimental
*
* Utilities for performing operations on file systems and their components,
* such as paths, regular files, and directories.
*
* @{
*/
class file_status;
_GLIBCXX_BEGIN_NAMESPACE_CXX11
class path;
class filesystem_error;
class directory_entry;
class directory_iterator;
class recursive_directory_iterator;
_GLIBCXX_END_NAMESPACE_CXX11
struct space_info
{
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
};
enum class file_type : signed char {
none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3,
block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
};
/// Bitmask type
enum class copy_options : unsigned short {
none = 0,
skip_existing = 1, overwrite_existing = 2, update_existing = 4,
recursive = 8,
copy_symlinks = 16, skip_symlinks = 32,
directories_only = 64, create_symlinks = 128, create_hard_links = 256
};
constexpr copy_options
operator&(copy_options __x, copy_options __y)
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr copy_options
operator|(copy_options __x, copy_options __y)
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr copy_options
operator^(copy_options __x, copy_options __y)
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr copy_options
operator~(copy_options __x)
{
using __utype = typename std::underlying_type<copy_options>::type;
return static_cast<copy_options>(~static_cast<__utype>(__x));
}
inline copy_options&
operator&=(copy_options& __x, copy_options __y)
{ return __x = __x & __y; }
inline copy_options&
operator|=(copy_options& __x, copy_options __y)
{ return __x = __x | __y; }
inline copy_options&
operator^=(copy_options& __x, copy_options __y)
{ return __x = __x ^ __y; }
/// Bitmask type
enum class perms : unsigned {
none = 0,
owner_read = 0400,
owner_write = 0200,
owner_exec = 0100,
owner_all = 0700,
group_read = 040,
group_write = 020,
group_exec = 010,
group_all = 070,
others_read = 04,
others_write = 02,
others_exec = 01,
others_all = 07,
all = 0777,
set_uid = 04000,
set_gid = 02000,
sticky_bit = 01000,
mask = 07777,
unknown = 0xFFFF,
add_perms = 0x10000,
remove_perms = 0x20000,
resolve_symlinks = 0x40000
};
constexpr perms
operator&(perms __x, perms __y)
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr perms
operator|(perms __x, perms __y)
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr perms
operator^(perms __x, perms __y)
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr perms
operator~(perms __x)
{
using __utype = typename std::underlying_type<perms>::type;
return static_cast<perms>(~static_cast<__utype>(__x));
}
inline perms&
operator&=(perms& __x, perms __y)
{ return __x = __x & __y; }
inline perms&
operator|=(perms& __x, perms __y)
{ return __x = __x | __y; }
inline perms&
operator^=(perms& __x, perms __y)
{ return __x = __x ^ __y; }
// Bitmask type
enum class directory_options : unsigned char {
none = 0, follow_directory_symlink = 1, skip_permission_denied = 2
};
constexpr directory_options
operator&(directory_options __x, directory_options __y)
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(
static_cast<__utype>(__x) & static_cast<__utype>(__y));
}
constexpr directory_options
operator|(directory_options __x, directory_options __y)
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(
static_cast<__utype>(__x) | static_cast<__utype>(__y));
}
constexpr directory_options
operator^(directory_options __x, directory_options __y)
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(
static_cast<__utype>(__x) ^ static_cast<__utype>(__y));
}
constexpr directory_options
operator~(directory_options __x)
{
using __utype = typename std::underlying_type<directory_options>::type;
return static_cast<directory_options>(~static_cast<__utype>(__x));
}
inline directory_options&
operator&=(directory_options& __x, directory_options __y)
{ return __x = __x & __y; }
inline directory_options&
operator|=(directory_options& __x, directory_options __y)
{ return __x = __x | __y; }
inline directory_options&
operator^=(directory_options& __x, directory_options __y)
{ return __x = __x ^ __y; }
typedef chrono::time_point<chrono::system_clock> file_time_type;
// operational functions
void copy(const path& __from, const path& __to, copy_options __options);
void copy(const path& __from, const path& __to, copy_options __options,
error_code&) noexcept;
bool copy_file(const path& __from, const path& __to, copy_options __option);
bool copy_file(const path& __from, const path& __to, copy_options __option,
error_code&) noexcept;
path current_path();
file_status status(const path&);
file_status status(const path&, error_code&) noexcept;
bool status_known(file_status) noexcept;
file_status symlink_status(const path&);
file_status symlink_status(const path&, error_code&) noexcept;
bool is_regular_file(file_status) noexcept;
bool is_symlink(file_status) noexcept;
// @} group filesystem
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace v1
} // namespace filesystem
} // namespace experimental
} // namespace std
#endif // C++11
#endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H
// Filesystem operational functions -*- C++ -*-
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your __option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file experimental/filesystem
* This is a TS C++ Library header.
*/
#ifndef _GLIBCXX_EXPERIMENTAL_FS_OPS_H
#define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <cstdint>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace experimental
{
namespace filesystem
{
inline namespace v1
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @ingroup filesystem
* @{
*/
path absolute(const path& __p, const path& __base = current_path());
path canonical(const path& __p, const path& __base = current_path());
path canonical(const path& p, error_code& ec);
path canonical(const path& p, const path& base, error_code& ec);
inline void
copy(const path& __from, const path& __to)
{ copy(__from, __to, copy_options::none); }
inline void
copy(const path& __from, const path& __to, error_code& __ec) noexcept
{ copy(__from, __to, copy_options::none, __ec); }
void copy(const path& __from, const path& __to, copy_options options);
void copy(const path& __from, const path& __to, copy_options options,
error_code& __ec) noexcept;
inline bool
copy_file(const path& __from, const path& __to)
{ return copy_file(__from, __to, copy_options::none); }
inline bool
copy_file(const path& __from, const path& __to, error_code& __ec) noexcept
{ return copy_file(__from, __to, copy_options::none, __ec); }
bool copy_file(const path& __from, const path& __to, copy_options __option);
bool copy_file(const path& __from, const path& __to, copy_options __option,
error_code& __ec) noexcept;
void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
error_code& __ec) noexcept;
bool create_directories(const path& __p);
bool create_directories(const path& __p, error_code& __ec) noexcept;
bool create_directory(const path& __p);
bool create_directory(const path& __p, error_code& __ec) noexcept;
bool create_directory(const path& __p, const path& attributes);
bool create_directory(const path& __p, const path& attributes,
error_code& __ec) noexcept;
void create_directory_symlink(const path& __to, const path& __new_symlink);
void create_directory_symlink(const path& __to, const path& __new_symlink,
error_code& __ec) noexcept;
void create_hard_link(const path& __to, const path& __new_hard_link);
void create_hard_link(const path& __to, const path& __new_hard_link,
error_code& __ec) noexcept;
void create_symlink(const path& __to, const path& __new_symlink);
void create_symlink(const path& __to, const path& __new_symlink,
error_code& __ec) noexcept;
path current_path();
path current_path(error_code& __ec);
void current_path(const path& __p);
void current_path(const path& __p, error_code& __ec) noexcept;
inline bool
exists(file_status __s) noexcept
{ return status_known(__s) && __s.type() != file_type::not_found; }
inline bool
exists(const path& __p)
{ return exists(status(__p)); }
inline bool
exists(const path& __p, error_code& __ec) noexcept
{ return exists(status(__p, __ec)); }
bool
equivalent(const path& __p1, const path& __p2);
bool
equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
uintmax_t file_size(const path& __p);
uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
uintmax_t hard_link_count(const path& __p);
uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
inline bool
is_block_file(file_status __s) noexcept
{ return __s.type() == file_type::block; }
inline bool
is_block_file(const path& __p)
{ return is_block_file(status(__p)); }
inline bool
is_block_file(const path& __p, error_code& __ec) noexcept
{ return is_block_file(status(__p, __ec)); }
inline bool
is_character_file(file_status __s) noexcept
{ return __s.type() == file_type::character; }
inline bool
is_character_file(const path& __p)
{ return is_character_file(status(__p)); }
inline bool
is_character_file(const path& __p, error_code& __ec) noexcept
{ return is_character_file(status(__p, __ec)); }
inline bool
is_directory(file_status __s) noexcept
{ return __s.type() == file_type::directory; }
inline bool
is_directory(const path& __p)
{ return is_directory(status(__p)); }
inline bool
is_directory(const path& __p, error_code& __ec) noexcept
{ return is_directory(status(__p, __ec)); }
bool is_empty(const path& __p);
bool is_empty(const path& __p, error_code& __ec) noexcept;
inline bool
is_fifo(file_status __s) noexcept
{ return __s.type() == file_type::fifo; }
inline bool
is_fifo(const path& __p)
{ return is_fifo(status(__p)); }
inline bool
is_fifo(const path& __p, error_code& __ec) noexcept
{ return is_fifo(status(__p, __ec)); }
inline bool
is_other(file_status __s) noexcept
{
return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
&& !is_symlink(__s);
}
inline bool
is_other(const path& __p)
{ return is_other(status(__p)); }
inline bool
is_other(const path& __p, error_code& __ec) noexcept
{ return is_other(status(__p, __ec)); }
inline bool
is_regular_file(file_status __s) noexcept
{ return __s.type() == file_type::regular; }
inline bool
is_regular_file(const path& __p)
{ return is_regular_file(status(__p)); }
inline bool
is_regular_file(const path& __p, error_code& __ec) noexcept
{ return is_regular_file(status(__p, __ec)); }
inline bool
is_socket(file_status __s) noexcept
{ return __s.type() == file_type::socket; }
inline bool
is_socket(const path& __p)
{ return is_socket(status(__p)); }
inline bool
is_socket(const path& __p, error_code& __ec) noexcept
{ return is_socket(status(__p, __ec)); }
inline bool
is_symlink(file_status __s) noexcept
{ return __s.type() == file_type::symlink; }
inline bool
is_symlink(const path& __p)
{ return is_symlink(symlink_status(__p)); }
inline bool
is_symlink(const path& __p, error_code& __ec) noexcept
{ return is_symlink(symlink_status(__p, __ec)); }
file_time_type last_write_time(const path& __p);
file_time_type last_write_time(const path& __p, error_code& __ec) noexcept;
void last_write_time(const path& __p, file_time_type new_time);
void last_write_time(const path& __p, file_time_type new_time,
error_code& __ec) noexcept;
void permissions(const path& __p, perms prms);
void permissions(const path& __p, perms prms, error_code& __ec) noexcept;
path read_symlink(const path& __p);
path read_symlink(const path& __p, error_code& __ec);
bool remove(const path& __p);
bool remove(const path& __p, error_code& __ec) noexcept;
uintmax_t remove_all(const path& __p);
uintmax_t remove_all(const path& __p, error_code& __ec) noexcept;
void rename(const path& __from, const path& __to);
void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
void resize_file(const path& __p, uintmax_t __size);
void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
space_info space(const path& __p);
space_info space(const path& __p, error_code& __ec) noexcept;
file_status status(const path& __p);
file_status status(const path& __p, error_code& __ec) noexcept;
inline bool status_known(file_status __s) noexcept
{ return __s.type() != file_type::none; }
file_status symlink_status(const path& __p);
file_status symlink_status(const path& __p, error_code& __ec) noexcept;
path system_complete(const path& __p);
path system_complete(const path& __p, error_code& __ec);
path temp_directory_path();
path temp_directory_path(error_code& __ec);
// @} group filesystem
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace v1
} // namespace filesystem
} // namespace experimental
} // namespace std
#endif // C++11
#endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H
......@@ -42,7 +42,7 @@
#if __cplusplus >= 201103L
#include <locale>
#if __cplusplus > 201103L
#include <sstream> // used in quoted.
#include <bits/quoted_string.h>
#endif
#endif
......@@ -450,127 +450,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_quoted_string_io 201304
_GLIBCXX_END_NAMESPACE_VERSION
namespace __detail {
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Struct for delimited strings.
*/
template<typename _String, typename _CharT>
struct _Quoted_string
{
static_assert(is_reference<_String>::value
|| is_pointer<_String>::value,
"String type must be pointer or reference");
_Quoted_string(_String __str, _CharT __del, _CharT __esc)
: _M_string(__str), _M_delim{__del}, _M_escape{__esc}
{ }
_Quoted_string&
operator=(_Quoted_string&) = delete;
_String _M_string;
_CharT _M_delim;
_CharT _M_escape;
};
/**
* @brief Inserter for quoted strings.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 2344 quoted()'s interaction with padding is unclear
*/
template<typename _CharT, typename _Traits>
auto&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const _Quoted_string<const _CharT*, _CharT>& __str)
{
std::basic_ostringstream<_CharT, _Traits> __ostr;
__ostr << __str._M_delim;
for (const _CharT* __c = __str._M_string; *__c; ++__c)
{
if (*__c == __str._M_delim || *__c == __str._M_escape)
__ostr << __str._M_escape;
__ostr << *__c;
}
__ostr << __str._M_delim;
return __os << __ostr.str();
}
/**
* @brief Inserter for quoted strings.
*
* _GLIBCXX_RESOLVE_LIB_DEFECTS
* DR 2344 quoted()'s interaction with padding is unclear
*/
template<typename _CharT, typename _Traits, typename _String>
auto&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const _Quoted_string<_String, _CharT>& __str)
{
std::basic_ostringstream<_CharT, _Traits> __ostr;
__ostr << __str._M_delim;
for (auto& __c : __str._M_string)
{
if (__c == __str._M_delim || __c == __str._M_escape)
__ostr << __str._M_escape;
__ostr << __c;
}
__ostr << __str._M_delim;
return __os << __ostr.str();
}
/**
* @brief Extractor for delimited strings.
* The left and right delimiters can be different.
*/
template<typename _CharT, typename _Traits, typename _Alloc>
auto&
operator>>(std::basic_istream<_CharT, _Traits>& __is,
const _Quoted_string<basic_string<_CharT, _Traits, _Alloc>&,
_CharT>& __str)
{
_CharT __c;
__is >> __c;
if (!__is.good())
return __is;
if (__c != __str._M_delim)
{
__is.unget();
__is >> __str._M_string;
return __is;
}
__str._M_string.clear();
std::ios_base::fmtflags __flags
= __is.flags(__is.flags() & ~std::ios_base::skipws);
do
{
__is >> __c;
if (!__is.good())
break;
if (__c == __str._M_escape)
{
__is >> __c;
if (!__is.good())
break;
}
else if (__c == __str._M_delim)
break;
__str._M_string += __c;
}
while (true);
__is.setf(__flags);
return __is;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Manipulator for quoted strings.
* @param __string String to quote.
......
......@@ -979,6 +979,22 @@ class StdExpStringViewPrinter:
def display_hint (self):
return 'string'
class StdExpPathPrinter:
"Print a std::experimental::filesystem::path"
def __init__ (self, typename, val):
self.val = val
self.list_visualizer = gdb.default_visualizer(val['_M_cmpts'])
def to_string (self):
path = self.val ['_M_pathname']
if self.list_visualizer:
list_head = self.val['_M_cmpts']['_M_impl']['_M_node']
if list_head.address != list_head['_M_next']:
cmpts = self.list_visualizer.to_string()
path = "%s [Components %s]" % (path, cmpts)
return path
# A "regular expression" printer which conforms to the
# "SubPrettyPrinter" protocol from gdb.printing.
class RxPrinter(object):
......@@ -1364,6 +1380,11 @@ def build_libstdcxx_dictionary ():
'optional', StdExpOptionalPrinter)
libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
'basic_string_view', StdExpStringViewPrinter)
# Filesystem TS components
libstdcxx_printer.add_version('std::experimental::filesystem::v1::',
'path', StdExpPathPrinter)
libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11',
'path', StdExpPathPrinter)
# Extensions.
libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter)
......
......@@ -77,7 +77,8 @@ case ${query} in
echo ${PCHFLAGS}
;;
--cxxldflags)
SECTIONLDFLAGS="@SECTION_LDFLAGS@ @LIBICONV@"
SECTIONLDFLAGS="@SECTION_LDFLAGS@ @LIBICONV@
-L${BUILD_DIR}/src/filesystem/.libs"
echo ${SECTIONLDFLAGS}
;;
*)
......
......@@ -22,7 +22,13 @@
include $(top_srcdir)/fragment.am
SUBDIRS = c++98 c++11
if ENABLE_FILESYSTEM_TS
filesystem_dir = filesystem
else
filesystem_dir =
endif
SUBDIRS = c++98 c++11 $(filesystem_dir)
# Cross compiler support.
if VTV_CYGMIN
......@@ -52,6 +58,9 @@ endif
vpath % $(top_srcdir)/src/c++98
vpath % $(top_srcdir)/src/c++11
if ENABLE_FILESYSTEM_TS
vpath % $(top_srcdir)/src/filesystem
endif
if GLIBCXX_LDBL_COMPAT
ldbl_compat_sources = compatibility-ldbl.cc
......
......@@ -123,7 +123,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DIST_SUBDIRS = c++98 c++11 filesystem
ABI_TWEAKS_SRCDIR = @ABI_TWEAKS_SRCDIR@
ACLOCAL = @ACLOCAL@
ALLOCATOR_H = @ALLOCATOR_H@
......@@ -346,7 +346,9 @@ WARN_CXXFLAGS = \
# -I/-D flags to pass when compiling.
AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
SUBDIRS = c++98 c++11
@ENABLE_FILESYSTEM_TS_FALSE@filesystem_dir =
@ENABLE_FILESYSTEM_TS_TRUE@filesystem_dir = filesystem
SUBDIRS = c++98 c++11 $(filesystem_dir)
@VTV_CYGMIN_FALSE@toolexeclib_LTLIBRARIES = libstdc++.la
# Cross compiler support.
......@@ -859,6 +861,7 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES
vpath % $(top_srcdir)/src/c++98
vpath % $(top_srcdir)/src/c++11
@ENABLE_FILESYSTEM_TS_TRUE@vpath % $(top_srcdir)/src/filesystem
# Use special rules for compatibility-ldbl.cc compilation, as we need to
# pass -mlong-double-64.
......
## Makefile for the GNU C++ Filesystem library.
##
## Copyright (C) 2014 Free Software Foundation, Inc.
##
## Process this file with automake to produce Makefile.in.
##
## This file is part of GCC.
##
## GCC is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3, or (at your option)
## any later version.
##
## GCC is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with GCC; see the file COPYING3. If not see
## <http://www.gnu.org/licenses/>.
include $(top_srcdir)/fragment.am
toolexeclib_LTLIBRARIES = libstdc++fs.la
headers =
sources = \
dir.cc \
ops.cc \
path.cc
# vpath % $(top_srcdir)/src/filesystem
libstdc__fs_la_SOURCES = $(sources)
# AM_CXXFLAGS needs to be in each subdirectory so that it can be
# modified in a per-library or per-sub-library way. Need to manually
# set this option because CONFIG_CXXFLAGS has to be after
# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
# as the occasion call for it.
AM_CXXFLAGS = \
$(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \
-std=gnu++14 \
$(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
AM_MAKEFLAGS = \
"gxx_include_dir=$(gxx_include_dir)"
# Libtool notes
# 1) In general, libtool expects an argument such as `--tag=CXX' when
# using the C++ compiler, because that will enable the settings
# detected when C++ support was being configured. However, when no
# such flag is given in the command line, libtool attempts to figure
# it out by matching the compiler name in each configuration section
# against a prefix of the command line. The problem is that, if the
# compiler name and its initial flags stored in the libtool
# configuration file don't match those in the command line, libtool
# can't decide which configuration to use, and it gives up. The
# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
# attempt to infer which configuration to use.
#
# The second tag argument, `--tag disable-shared` means that libtool
# only compiles each source once, for static objects. In actuality,
# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
# the libtool command that is used create the object, which is
# suitable for shared libraries. The `--tag disable-shared` must be
# placed after --tag CXX lest things CXX undo the affect of
# disable-shared.
# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
# last. (That way, things like -O2 passed down from the toplevel can
# be overridden by --enable-debug.)
LTCXXCOMPILE = \
$(LIBTOOL) --tag CXX --tag disable-shared \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CXX) $(TOPLEVEL_INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
# 3) We'd have a problem when building the shared libstdc++ object if
# the rules automake generates would be used. We cannot allow g++ to
# be used since this would add -lstdc++ to the link line which of
# course is problematic at this point. So, we get the top-level
# directory to configure libstdc++-v3 to use gcc as the C++
# compilation driver.
CXXLINK = \
$(LIBTOOL) --tag CXX --tag disable-shared \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
# By adding these files here, automake will remove them for 'make clean'
CLEANFILES = stamp-*
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 15.1 Absolute [fs.op.absolute]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
VERIFY( absolute(p).is_absolute() );
}
void
test02()
{
path p1("/");
VERIFY( absolute(p1) == p1 );
VERIFY( absolute(p1, "/bar") == p1 );
path p2("/foo");
VERIFY( absolute(p2) == p2 );
VERIFY( absolute(p2, "/bar") == p2 );
path p3("foo");
VERIFY( absolute(p3) != p3 );
VERIFY( absolute(p3, "/bar") == "/bar/foo" );
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 15.3 Copy [fs.op.copy]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
VERIFY( absolute(p).is_absolute() );
}
void
test02()
{
path p1("/");
VERIFY( absolute(p1) == p1 );
VERIFY( absolute(p1, "/bar") == p1 );
path p2("/foo");
VERIFY( absolute(p2) == p2 );
VERIFY( absolute(p2, "/bar") == p2 );
path p3("foo");
VERIFY( absolute(p3) != p3 );
VERIFY( absolute(p3, "/bar") == "/bar/foo" );
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 15.11 Current path [fs.op.current_path]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
namespace fs = std::experimental::filesystem;
void
test01()
{
fs::path dot(".");
fs::path cwd = fs::current_path();
std::error_code ec;
fs::path cwd2 = fs::current_path(ec);
VERIFY( cwd == cwd2 );
}
void
test02()
{
auto oldwd = fs::current_path();
auto tmpdir = fs::temp_directory_path();
current_path(tmpdir);
VERIFY( fs::current_path() == tmpdir );
std::error_code ec;
current_path(oldwd, ec);
VERIFY( fs::current_path() == oldwd );
VERIFY( fs::current_path(ec) == oldwd );
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.3 path appends [path.append]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
const path p("/foo/bar");
path pp = p;
pp /= p;
VERIFY( pp.native() == "/foo/bar/foo/bar" );
path q("baz");
path qq = q;
qq /= q;
VERIFY( qq.native() == "baz/baz" );
q /= p;
VERIFY( q.native() == "baz/foo/bar" );
path r = "";
r /= path();
VERIFY( r.empty() );
r /= path("rel");
VERIFY( !r.is_absolute() );
path s = "dir/";
s /= path("/file");
VERIFY( s.native() == "dir//file" );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
using __gnu_test::compare_paths;
void
test01()
{
for (std::string s : __gnu_test::test_paths)
{
path p0 = s, p1, p2, p3, p4;
p1 = s;
compare_paths(p0, p1);
p2 = s.c_str();
compare_paths(p0, p2);
std::wstring ws(s.begin(), s.end());
p3 = ws;
compare_paths(p0, p3);
p4 = ws.c_str();
compare_paths(p0, p4);
}
}
void
test02()
{
for (std::string s : __gnu_test::test_paths)
{
path p0 = s, p1, p2, p3, p4, p5, p6, p7, p8;
p1.assign(s);
compare_paths(p0, p1);
p2.assign( s.begin(), s.end() );
compare_paths(p0, p2);
p3.assign( s.c_str() );
compare_paths(p0, p3);
p4.assign( s.c_str(), s.c_str() + s.size() );
compare_paths(p0, p4);
std::wstring ws(s.begin(), s.end());
p5.assign(ws);
compare_paths(p0, p5);
p6.assign( ws.begin(), ws.end() );
compare_paths(p0, p6);
p7.assign( ws.c_str() );
compare_paths(p0, p7);
p8.assign( ws.c_str(), ws.c_str() + ws.size() );
compare_paths(p0, p8);
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/filesystem>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
using __gnu_test::compare_paths;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
path copy;
copy = p;
__gnu_test::compare_paths(p, copy);
}
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path copy = p;
path move;
move = std::move(copy);
__gnu_test::compare_paths(p, move);
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.8 path compare [path.compare]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
path p("/foo/bar");
VERIFY( p.compare(p) == 0 );
VERIFY( p.compare("/foo//bar") == 0 );
path q("/foo/baz");
VERIFY( p.compare(q) < 0 );
VERIFY( q.compare(p) > 0 );
path r("/foo/bar/.");
VERIFY( p.compare(r) < 0 );
VERIFY( path("a/b/").compare("a/b/.") == 0 );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.8 path compare [path.compare]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
const path p0 = "/a/a/b/b";
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.compare(p) == 0 );
int cmp = p.compare(p0);
if (cmp == 0)
VERIFY( p0.compare(p) == 0 );
else if (cmp < 0)
VERIFY( p0.compare(p) > 0 );
else if (cmp > 0)
VERIFY( p0.compare(p) < 0 );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.8 path compare [path.compare]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
const std::string s0 = "/a/a/b/b";
const path p0 = s0;
for (const std::string& s : __gnu_test::test_paths)
{
path p(s);
VERIFY( p.compare(s) == 0 );
VERIFY( p.compare(s.c_str()) == 0 );
VERIFY( p.compare(p0) == p.compare(s0) );
VERIFY( p.compare(p0) == p.compare(s0.c_str()) );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.4 path concatenation [path.concat]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
const path p("/foo/bar");
path pp = p;
pp += p;
VERIFY( pp.native() == "/foo/bar/foo/bar" );
VERIFY( std::distance(pp.begin(), pp.end()) == 5 );
path q("foo/bar");
path qq = q;
qq += q;
VERIFY( qq.native() == "foo/barfoo/bar" );
VERIFY( std::distance(qq.begin(), qq.end()) == 3 );
q += p;
VERIFY( q.native() == "foo/bar/foo/bar" );
VERIFY( std::distance(q.begin(), q.end()) == 4 );
}
void
test02()
{
for (path p : __gnu_test::test_paths)
{
auto prior_native = p.native();
path x("//blah/di/blah");
p += x;
VERIFY( p.native() == prior_native + x.native() );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.4 path concatenation [path.concat]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
path p("/");
p += path::string_type("foo");
VERIFY( p.filename() == "foo" );
p += "bar";
VERIFY( p.filename() == "foobar" );
p += '/';
VERIFY( p.parent_path() == "/foobar" && p.filename() == "." );
p += L"baz.txt";
VERIFY( p.filename() == "baz.txt" );
p.concat("/dir/");
VERIFY( p.parent_path() == "/foobar/baz.txt/dir" && p.filename() == "." );
std::string file = "file";
p.concat(file.begin(), file.end());
VERIFY( p.filename() == "file" );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.1 path constructors [path.construct]
#include <experimental/filesystem>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
path copy = p;
__gnu_test::compare_paths(p, copy);
}
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path copy = p;
path move = std::move(copy);
__gnu_test::compare_paths(p, move);
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.1 path constructors [path.construct]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
path p;
VERIFY( p.empty() );
VERIFY( !p.has_root_path() );
VERIFY( !p.has_root_name() );
VERIFY( !p.has_root_directory() );
VERIFY( !p.has_relative_path() );
VERIFY( !p.has_parent_path() );
VERIFY( !p.has_filename() );
VERIFY( !p.has_stem() );
VERIFY( !p.has_extension() );
VERIFY( !p.is_absolute() );
VERIFY( p.is_relative() );
VERIFY( std::distance(p.begin(), p.end()) == 0 );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.1 path constructors [path.construct]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
path p("/foo/bar", std::locale::classic());
VERIFY( p.string() == "/foo/bar" );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.1 path constructors [path.construct]
#include <experimental/filesystem>
#include <string>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
using __gnu_test::compare_paths;
void
test01()
{
for (std::string s : __gnu_test::test_paths)
{
path p1 = s;
path p2( s.begin(), s.end() );
path p3( s.c_str() );
path p4( s.c_str(), s.c_str() + s.size() );
std::wstring ws(s.begin(), s.end());
path p5 = ws;
path p6( ws.begin(), ws.end() );
path p7( ws.c_str() );
path p8( ws.c_str(), ws.c_str() + ws.size() );
compare_paths(p1, p2);
compare_paths(p1, p3);
compare_paths(p1, p4);
compare_paths(p1, p5);
compare_paths(p1, p6);
compare_paths(p1, p7);
compare_paths(p1, p8);
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo/bar.txt").extension() == path(".txt") );
VERIFY( path("/foo/bar.baz.txt").extension() == path(".txt") );
VERIFY( path(".bar.baz.txt").extension() == path(".txt") );
VERIFY( path(".hidden").extension() == path(".hidden") );
VERIFY( path().extension() == path() );
VERIFY( path(".").extension() == path() );
VERIFY( path("..").extension() == path() );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
auto stem = p.stem();
auto ext = p.extension();
auto file = p.filename();
VERIFY( stem.native() + ext.native() == file.native() );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo/bar.txt").filename() == "bar.txt" );
VERIFY( path("/").filename() == "/" );
VERIFY( path(".").filename() == "." );
VERIFY( path("..").filename() == ".." );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path f = p.filename();
if (p.empty())
VERIFY( f.empty() );
else
VERIFY( f == *--p.end() );
if (p != p.root_path())
VERIFY( !f.has_root_path() );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
path p0;
VERIFY( p0.parent_path() == p0 );
path p1 = "foo";
VERIFY( p1.parent_path() == p0 );
path p2 = "foo/bar";
VERIFY( p2.parent_path() == p1 );
path p3 = "/foo/bar";
VERIFY( p3.parent_path() == path("/foo") );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path pp;
for (auto i = p.begin(), end = --p.end(); i != end; ++i)
{
pp /= *i;
}
VERIFY( p.parent_path() == pp );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
path p1 = "foo";
VERIFY( p1.relative_path() == p1 );
path p2 = "foo/bar";
VERIFY( p2.relative_path() == p2 );
path p3 = "/foo/bar";
VERIFY( p3.relative_path() == p2 );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
bool after_root = false;
const path prel = p.relative_path();
VERIFY( !prel.has_root_name() );
path rel;
for (const auto& cmpt : p)
{
if (!cmpt.has_root_path())
after_root = true;
if (after_root)
rel /= cmpt;
}
VERIFY( prel == rel );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
path p1 = "foo/bar";
VERIFY( p1.root_directory() == path() );
path p2 = "/foo/bar";
VERIFY( p2.root_directory() == path("/") );
path p3 = "//foo";
VERIFY( p3.root_directory() == path() );
path p4 = "///foo";
VERIFY( p4.root_directory() == path("/") );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path rootdir = p.root_directory();
// If root-directory is composed of 'slash name',
// 'slash' is excluded from the returned string.
if (!rootdir.empty() && rootdir.native() != "/")
VERIFY( rootdir.native()[0] != '/' );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo/bar.txt").extension() == ".txt" );
VERIFY( path("/foo/bar.baz.txt").extension() == ".txt" );
VERIFY( path(".").extension().empty() );
VERIFY( path("..").extension().empty() );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
path p1 = "foo/bar";
VERIFY( p1.root_path() == path() );
path p2 = "/foo/bar";
VERIFY( p2.root_path() == path("/") );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path rootp = p.root_path();
path rootn = p.root_name();
path rootd = p.root_directory();
VERIFY( rootp == (rootn / rootd) );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo/bar.txt").stem() == path("bar") );
path p = "foo.bar.baz.tar";
std::vector<std::string> v;
for (; !p.extension().empty(); p = p.stem())
v.push_back(p.extension().native());
VERIFY( v.at(0) == ".tar" );
VERIFY( v.at(1) == ".baz" );
VERIFY( v.at(2) == ".bar" );
VERIFY( path(".hidden").stem() == path() );
VERIFY( path().stem() == path() );
VERIFY( path(".").stem() == path(".") );
VERIFY( path("..").stem() == path("..") );
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.7 path generic format observers [path.generic.obs]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
path p2(p), p3;
p2.swap(p3);
VERIFY( p2 == path() );
VERIFY( p3 == p );
p2.swap(p3);
VERIFY( p2 == p );
VERIFY( p3 == path() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.5 path iterators [path.itr]
#include <experimental/filesystem>
#include <vector>
#include <algorithm>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
path p;
VERIFY( p.begin() == p.end() );
std::vector<path> v, v2;
p = "/";
v.assign(p.begin(), p.end());
v2 = { "/" };
VERIFY( v == v2 );
p = "filename";
v.assign(p.begin(), p.end());
v2 = { "filename" };
VERIFY( v == v2 );
p = "dir/";
v.assign(p.begin(), p.end());
v2 = { "dir", "." };
VERIFY( v == v2 );
p = "//rootname/dir/";
v.assign(p.begin(), p.end());
v2 = { "//rootname", "/", "dir", "." };
VERIFY( v == v2 );
p = "//rootname/dir/filename";
v.assign(p.begin(), p.end());
v2 = { "//rootname", "/", "dir", "filename" };
VERIFY( v == v2 );
}
void
test02()
{
using reverse_iterator = std::reverse_iterator<path::iterator>;
std::vector<path> fwd, rev;
for (const path& p : __gnu_test::test_paths)
{
const auto begin = p.begin(), end = p.end();
fwd.assign(begin, end);
rev.assign(reverse_iterator(end), reverse_iterator(begin));
VERIFY( fwd.size() == rev.size() );
VERIFY( std::equal(fwd.begin(), fwd.end(), rev.rbegin()) );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.5 path modifiers [path.modifiers]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
for (path p : __gnu_test::test_paths)
{
path empty;
p.clear();
VERIFY( p.empty() );
__gnu_test::compare_paths(p, empty);
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.5 path modifiers [path.modifiers]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
template<typename T, T sep>
struct checker
{
static void check(const char* s) { }
};
template<>
struct checker<char, '/'>
{
static void check()
{
VERIFY( path("foo/bar").make_preferred() == "foo/bar" );
}
};
template<>
struct checker<wchar_t, L'\\'>
{
static void check()
{
VERIFY( path("foo/bar").make_preferred() == L"foo\\bar" );
}
};
void
test01()
{
checker<path::value_type, path::preferred_separator>::check();
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.5 path modifiers [path.modifiers]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo").remove_filename() == "/" );
VERIFY( path("/").remove_filename() == "" );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path p2(p);
p2.remove_filename();
p2 /= p.filename();
VERIFY( p2 == p );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.5 path modifiers [path.modifiers]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo.txt").replace_extension("cpp") == "/foo.cpp" );
VERIFY( path("/foo.txt").replace_extension(".cpp") == "/foo.cpp" );
VERIFY( path("/").replace_extension("bar") == "/.bar" );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path p2 = p;
VERIFY(p2.replace_extension(p2.extension()) == p);
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.5 path modifiers [path.modifiers]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( path("/foo").replace_filename("bar") == "/bar" );
VERIFY( path("/").replace_filename("bar") == "bar" );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path p2(p);
p2.replace_filename(p.filename());
VERIFY( p2 == p );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.5 path modifiers [path.modifiers]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
const path p("/foo/bar");
path p1;
path p2 = p;
p1.swap(p2);
VERIFY( p2.empty() );
__gnu_test::compare_paths(p1, p);
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.6 path non-member functions [path.non-member]
#include <experimental/filesystem>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
using std::experimental::filesystem::path;
void
test01()
{
VERIFY( hash_value(path("a//b")) == hash_value(path("a/b")) );
VERIFY( hash_value(path("a/")) == hash_value(path("a/.")) );
}
void
test02()
{
for (const path& p : __gnu_test::test_paths)
{
path pp = p.native();
VERIFY( hash_value(p) == hash_value(pp) );
}
}
int
main()
{
test01();
test02();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const std::string& s : __gnu_test::test_paths)
{
VERIFY( s.empty() == path(s).empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_extension() == !p.extension().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_filename() == !p.filename().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_parent_path() == !p.parent_path().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_relative_path() == !p.relative_path().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_root_directory() == !p.root_directory().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_root_name() == !p.root_name().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_root_path() == !p.root_path().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.has_stem() == !p.stem().empty() );
}
}
int
main()
{
test01();
}
// { dg-options "-std=gnu++11 -lstdc++fs" }
// { dg-require-filesystem-ts "" }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 8.4.9 path decomposition [path.decompose]
#include <experimental/filesystem>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_fs.h>
using std::experimental::filesystem::path;
void
test01()
{
for (const path& p : __gnu_test::test_paths)
{
VERIFY( p.is_relative() == !p.is_absolute() );
}
}
int
main()
{
test01();
}
......@@ -223,6 +223,15 @@ proc dg-require-little-endian { args } {
return
}
proc dg-require-filesystem-ts { args } {
if { ![ check_v3_target_filesystem_ts ] } {
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
return
}
return
}
proc add_options_for_no_pch { flags } {
# This forces any generated and possibly included PCH to be invalid.
return "-D__GLIBCXX__=99999999"
......
......@@ -1895,6 +1895,53 @@ proc check_v3_target_little_endian { } {
return $et_little_endian
}
proc check_v3_target_filesystem_ts { } {
global et_filesystem_ts
global tool
if { ![info exists et_filesystem_ts_target_name] } {
set et_filesystem_ts_target_name ""
}
# If the target has changed since we set the cached value, clear it.
set current_target [current_target_name]
if { $current_target != $et_filesystem_ts_target_name } {
verbose "check_v3_target_filesystem_ts: `$et_filesystem_ts_target_name'" 2
set et_filesystem_ts_target_name $current_target
if [info exists et_filesystem_ts] {
verbose "check_v3_target_filesystem_ts: removing cached result" 2
unset et_filesystem_ts
}
}
if [info exists et_filesystem_ts] {
verbose "check_v3_target_filesystem_ts: using cached result" 2
} else {
set et_filesystem_ts 0
# Set up and preprocess a C++ test program that depends
# on debug mode activated.
set src filesystem_ts[pid].cc
set f [open $src "w"]
puts $f "#include <experimental/filesystem>"
puts $f "#if ! __cpp_lib_experimental_filesystem"
puts $f "# error No Filesystem TS support"
puts $f "#endif"
close $f
set lines [v3_target_compile $src /dev/null preprocess ""]
file delete $src
if [string match "" $lines] {
# No error message, preprocessing succeeded.
set et_filesystem_ts 1
}
}
verbose "check_v3_target_filesystem_ts: $et_filesystem_ts" 2
return $et_filesystem_ts
}
set additional_prunes ""
if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
......
// -*- C++ -*-
// Filesystem utils for the C++ library testsuite.
//
// Copyright (C) 2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
#ifndef _TESTSUITE_FS_H
#define _TESTSUITE_FS_H 1
#include <experimental/filesystem>
#include <iostream>
#include <string>
namespace __gnu_test
{
#define PATH_CHK(p1, p2, fn) \
if ( p1.fn() != p2.fn() ) \
throw std::experimental::filesystem::filesystem_error( #fn, p1, p2, \
std::make_error_code(std::errc::invalid_argument) )
void
compare_paths(const std::experimental::filesystem::path& p1,
const std::experimental::filesystem::path& p2)
{
// std::cout << "Comparing " << p1 << " and " << p2 << std::endl;
PATH_CHK( p1, p2, string );
PATH_CHK( p1, p2, empty );
PATH_CHK( p1, p2, has_root_path );
PATH_CHK( p1, p2, has_root_name );
PATH_CHK( p1, p2, has_root_directory );
PATH_CHK( p1, p2, has_relative_path );
PATH_CHK( p1, p2, has_parent_path );
PATH_CHK( p1, p2, has_filename );
PATH_CHK( p1, p2, has_stem );
PATH_CHK( p1, p2, has_extension );
PATH_CHK( p1, p2, is_absolute );
PATH_CHK( p1, p2, is_relative );
auto d1 = std::distance(p1.begin(), p1.end());
auto d2 = std::distance(p2.begin(), p2.end());
if( d1 != d2 )
throw std::experimental::filesystem::filesystem_error(
"distance(begin, end)", p1, p2,
std::make_error_code(std::errc::invalid_argument) );
}
const std::string test_paths[] = {
"", "/", "//", "/.", "/./", "/a", "/a/", "/a//", "/a/b/c/d", "/a//b",
"a", "a/b", "a/b/", "a/b/c", "a/b/c.d", "a/b/..", "a/b/c.", "a/b/.c"
};
} // namespace __gnu_test
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment