mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 03:07:36 +02:00
Minor cleanup
This commit is contained in:
15
src/os.cc
15
src/os.cc
@ -206,7 +206,7 @@ void buffered_file::close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int buffered_file::descriptor() const {
|
int buffered_file::descriptor() const {
|
||||||
#ifdef fileno // fileno is a macro on OpenBSD so we cannot use FMT_POSIX_CALL.
|
#ifdef fileno // fileno is a macro on OpenBSD so we cannot use FMT_POSIX_CALL.
|
||||||
int fd = fileno(file_);
|
int fd = fileno(file_);
|
||||||
#else
|
#else
|
||||||
int fd = FMT_POSIX_CALL(fileno(file_));
|
int fd = FMT_POSIX_CALL(fileno(file_));
|
||||||
@ -351,9 +351,10 @@ buffered_file file::fdopen(const char* mode) {
|
|||||||
# else
|
# else
|
||||||
FILE* f = FMT_POSIX_CALL(fdopen(fd_, mode));
|
FILE* f = FMT_POSIX_CALL(fdopen(fd_, mode));
|
||||||
# endif
|
# endif
|
||||||
if (!f)
|
if (!f) {
|
||||||
FMT_THROW(system_error(
|
FMT_THROW(system_error(
|
||||||
errno, FMT_STRING("cannot associate stream with file descriptor")));
|
errno, FMT_STRING("cannot associate stream with file descriptor")));
|
||||||
|
}
|
||||||
buffered_file bf(f);
|
buffered_file bf(f);
|
||||||
fd_ = -1;
|
fd_ = -1;
|
||||||
return bf;
|
return bf;
|
||||||
@ -361,13 +362,13 @@ buffered_file file::fdopen(const char* mode) {
|
|||||||
|
|
||||||
# if defined(_WIN32) && !defined(__MINGW32__)
|
# if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
file file::open_windows_file(wcstring_view path, int oflag) {
|
file file::open_windows_file(wcstring_view path, int oflag) {
|
||||||
int fd_ = -1;
|
int fd = -1;
|
||||||
auto err =
|
auto err = _wsopen_s(&fd, path.c_str(), oflag, _SH_DENYNO, default_open_mode);
|
||||||
_wsopen_s(&fd_, path.c_str(), oflag, _SH_DENYNO, default_open_mode);
|
if (fd == -1) {
|
||||||
if (fd_ == -1)
|
|
||||||
FMT_THROW(system_error(err, FMT_STRING("cannot open file {}"),
|
FMT_THROW(system_error(err, FMT_STRING("cannot open file {}"),
|
||||||
detail::utf16_to_utf8(path.c_str()).c_str()));
|
detail::utf16_to_utf8(path.c_str()).c_str()));
|
||||||
return file(fd_);
|
}
|
||||||
|
return file(fd);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user