Skip to content

Commit df6bab2

Browse files
authored
Refactor timestamp conversion and enhance POSIX linkat functionality (#1215)
- Updated `unix_timestamp_to_time_t` function signature for consistency. - Improved handling of `posix_linkat` and `native_linkat` functions to manage `symlink_nofollow` flags more effectively. - Adjusted conditional compilation checks in `linux_getrandom.h` and `white_hole.h` for better compatibility across platforms.
1 parent 10ad14c commit df6bab2

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

include/fast_io_hosted/filesystem/dos_at.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ inline
201201
constexpr
202202
#endif
203203
::std::time_t
204-
unix_timestamp_to_time_t(unix_timestamp_option opt) noexcept
204+
unix_timestamp_to_time_t(unix_timestamp_option opt)
205205
{
206206
switch (opt.flags)
207207
{

include/fast_io_hosted/filesystem/posix_at.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,17 @@ template <::fast_io::constructible_to_os_c_str old_path_type, ::fast_io::constru
747747
inline void posix_linkat(posix_at_entry oldent, old_path_type const &oldpath, posix_at_entry newent,
748748
new_path_type const &newpath, posix_at_flags flags = posix_at_flags::symlink_nofollow)
749749
{
750+
if ((flags & posix_at_flags::symlink_nofollow) == posix_at_flags::symlink_nofollow)
751+
{
752+
flags &= ~posix_at_flags::symlink_nofollow;
753+
}
754+
else
755+
{
756+
#ifdef AT_SYMLINK_FOLLOW
757+
flags |= static_cast<posix_at_flags>(AT_SYMLINK_FOLLOW);
758+
#endif
759+
}
760+
750761
details::posix_deal_with22<details::posix_api_22::linkat>(oldent.fd, oldpath, newent.fd, newpath,
751762
static_cast<int>(flags));
752763
}
@@ -755,6 +766,17 @@ template <::fast_io::constructible_to_os_c_str old_path_type, ::fast_io::constru
755766
inline void native_linkat(posix_at_entry oldent, old_path_type const &oldpath, posix_at_entry newent,
756767
new_path_type const &newpath, posix_at_flags flags = posix_at_flags::symlink_nofollow)
757768
{
769+
if ((flags & posix_at_flags::symlink_nofollow) == posix_at_flags::symlink_nofollow)
770+
{
771+
flags &= ~posix_at_flags::symlink_nofollow;
772+
}
773+
else
774+
{
775+
#ifdef AT_SYMLINK_FOLLOW
776+
flags |= static_cast<posix_at_flags>(AT_SYMLINK_FOLLOW);
777+
#endif
778+
}
779+
758780
details::posix_deal_with22<details::posix_api_22::linkat>(oldent.fd, oldpath, newent.fd, newpath,
759781
static_cast<int>(flags));
760782
}

include/fast_io_hosted/white_hole/linux_getrandom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#if !(defined(__linux__) && defined(__NR_getrandom)) && !__has_include(<sys/random.h>)
2+
#if !(defined(__linux__) && defined(__NR_getrandom)) && __has_include(<sys/random.h>)
33
#include <sys/random.h>
44
#endif
55

include/fast_io_hosted/white_hole/white_hole.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ concept minimum_buffer_input_stream_require_size_impl =
2525

2626
} // namespace fast_io::details
2727
#if ((defined(__linux__) && defined(__NR_getrandom)) || \
28-
(!defined(__linux__) && __has_include(<sys/random.h>))) && !defined(__wasi__) && !defined(__DARWIN_C_LEVEL) && !defined(__CYGWIN__)
28+
(!(defined(__linux__) && defined(__NR_getrandom)) && __has_include(<sys/random.h>))) && !defined(__wasi__) && !defined(__DARWIN_C_LEVEL) && !defined(__CYGWIN__)
2929
#include "linux_getrandom.h"
3030
#endif
3131
#if ((defined(__linux__) && defined(__GLIBC__)) || (defined(__BSD_VISIBLE) && !defined(__DARWIN_C_LEVEL))) && 0

0 commit comments

Comments
 (0)