Commit Graph

15 Commits

Author SHA1 Message Date
Eric Fiselier
508f208ae9 Fix LWG2683 - filesystem::copy() should always clear the user-provided error_code
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-11 22:18:09 +00:00
Eric Fiselier
051593845d Workaround missing C++14 constexpr semantics in filesystem
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283714 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-10 05:19:59 +00:00
Eric Fiselier
fd0e761473 Remove use of int128_t inside the filesystem implementation
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-10 04:22:58 +00:00
Eric Fiselier
c0f860c946 Partially revert overflow checking in last_write_time
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282660 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-29 01:01:26 +00:00
Eric Fiselier
d5fc5ca37f Improve 'last_write_time(...)' accuracy and detect overflow errors.
The ::stat struct on Linux, FreeBSD, and OS X  provides the access and
modification times as an instance of 'timespec', which has a nanosecond
resolution. The 'st_mtime' and 'st_atime' members simply reference the 'tv_sec'
value of the timespec struct. This patch changes 'last_write_time(...)' so that
it extracts both the seconds and nanoseconds values of the last modification
time, providing a more accurate implementation of 'last_write_time(...)'.

Additionally this patch fixes a possible signed integer overflow bug. The
'file_time_type' type cannot represent all possible values returned by
the filesystem. Attempting to construct a 'file_time_type' from one of these
values is undefined behavior. This patch avoids that UB by detecting possible
overflows before the conversion.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282634 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-28 21:16:58 +00:00
Eric Fiselier
fbdbb36015 Fix possible division by zero
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282468 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-27 02:13:27 +00:00
Marshall Clow
e7acb0e5be Followon to r279744. Find the other exception types and make __throw_XXX routines (and call them). Remove the generic __libcpp_throw routine, since no one uses it anymore.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279763 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25 17:47:09 +00:00
Eric Fiselier
55e084dd4d Cleanup filesystem::permissions ever more.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273392 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 07:57:38 +00:00
Eric Fiselier
e1a1a1ffb7 Avoid unnecessary stat call in filesystem::permissions implementation.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273391 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 07:24:00 +00:00
Eric Fiselier
7c96ddb563 Implement LWG issue 2720. Replace perms::resolve_symlinks with perms::symlink_nofollow.
This changes how filesystem::permissions(p, perms) handles symlinks. Previously
symlinks were not resolved by default instead only getting resolved when
"perms::resolve_symlinks" was used. After this change symlinks are resolved
by default and perms::symlink_nofollow must be given to change this.

This issue has not yet been moved to Ready status, and I will revert if it
doesn't get moved at the current meeting. However I feel confident that it
will and it's nice to have implementations when moving issues.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273328 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 22:42:42 +00:00
Eric Fiselier
70f7afec38 Fix bugs in last_write_time implementation.
* Fix passing a negative number as either tv_usec or tv_nsec. When file_time_type
  is negative and has a non-zero sub-second value we subtract 1 from tv_sec
  and make the sub-second duration positive.

* Detect and report when 'file_time_type' cannot be represented by time_t. This
  happens when using large/small file_time_type values with a 32 bit time_t.

There is more work to be done in the implementation. It should start to use
stat's st_mtim or st_mtimeval if it's provided as an extension. That way
we can provide a better resolution.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273103 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-19 02:04:49 +00:00
Eric Fiselier
2730c251ae Remove Apple specific guard for utimensat. Use !defined(UTIME_OMIT) instead.
As pointed out by @majnemer this is a better way to detect utimensat on all
platforms. The Apple specific guard is unneeded.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273093 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 19:11:40 +00:00
Eric Fiselier
7840a8ca84 Use utimes instead of utimensat when !defined(UTIME_OMIT). Fixes build for older GLIBC versions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273088 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 17:37:04 +00:00
Eric Fiselier
591e18f6aa Add additional tests in an attempt to diagnose ARM test failures.
Currently 4 tests are failing on the ARM buildbot. To try and diagnose each
of the failures this patch does the following:

1) path.itr/iterator.pass.cpp
   * Temporarily print iteration sequence to see where its failing.

2) path.native.obs/string_alloc.pass.cpp
   * Remove test that ::new is not called when constructing a short string
     that requires a conversion. Since during the conversion global locale
     objects might be constructed.

3) fs.op.funcs/space.pass.cpp
   * Explicitly use uintmax_t in the implementation of space, hopefully
     preventing possible overflows.
   * Add additional tests that check for overflow is the calculation of the
     space_info values.
   * Add additional tests for the values returned from statfvs.

4) fs.op.funcs/last_write_time.pass.cpp
   * No changes made yet.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273075 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 02:11:48 +00:00
Eric Fiselier
6e9a694dce Add Filesystem TS -- Complete
Add the completed std::experimental::filesystem implementation and tests.
The implementation supports C++11 or newer.

The TS is built as part of 'libc++experimental.a'. Users of the TS need to
manually link this library. Building and testing the TS can be disabled using
the CMake option '-DLIBCXX_ENABLE_FILESYSTEM=OFF'.

Currently 'libc++experimental.a' is not installed by default. To turn on the
installation of the library use '-DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON'.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273034 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 19:46:40 +00:00