Fix BufferefFile test on Windows.
This commit is contained in:
parent
564da25932
commit
2dad1690c8
10
posix.cc
10
posix.cc
@ -71,13 +71,9 @@ fmt::BufferedFile::~BufferedFile() FMT_NOEXCEPT(true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt::BufferedFile::BufferedFile(fmt::StringRef filename, fmt::StringRef mode) {
|
fmt::BufferedFile::BufferedFile(fmt::StringRef filename, fmt::StringRef mode) {
|
||||||
for (;;) {
|
FMT_RETRY_VAL(file_, FMT_SYSTEM(fopen(filename.c_str(), mode.c_str())), 0);
|
||||||
file_ = FMT_SYSTEM(fopen(filename.c_str(), mode.c_str()));
|
if (!file_)
|
||||||
if (file_)
|
throw SystemError(errno, "cannot open file");
|
||||||
return;
|
|
||||||
if (errno != EINTR)
|
|
||||||
throw SystemError(errno, "cannot open file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fmt::BufferedFile::close() {
|
void fmt::BufferedFile::close() {
|
||||||
|
9
posix.h
9
posix.h
@ -63,16 +63,19 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Retries the expression while it evaluates to -1 and error equals to EINTR.
|
// Retries the expression while it evaluates to error_result and errno
|
||||||
|
// equals to EINTR.
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# define FMT_RETRY(result, expression) \
|
# define FMT_RETRY_VAL(result, expression, error_result) \
|
||||||
do { \
|
do { \
|
||||||
result = (expression); \
|
result = (expression); \
|
||||||
} while (result == -1 && errno == EINTR)
|
} while (result == error_result && errno == EINTR)
|
||||||
#else
|
#else
|
||||||
# define FMT_RETRY(result, expression) result = (expression)
|
# define FMT_RETRY(result, expression) result = (expression)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
|
||||||
|
|
||||||
namespace fmt {
|
namespace fmt {
|
||||||
|
|
||||||
// An error code.
|
// An error code.
|
||||||
|
Loading…
Reference in New Issue
Block a user