11 #ifndef _CRT_SECURE_NO_WARNINGS 12 # define _CRT_SECURE_NO_WARNINGS 18 #include <sys/types.h> 27 # define O_CREAT _O_CREAT 28 # define O_TRUNC _O_TRUNC 31 # define S_IRUSR _S_IREAD 35 # define S_IWUSR _S_IWRITE 39 # define _SH_DENYNO 0x40 55 inline unsigned convert_rwcount(std::size_t
count) {
60 typedef ssize_t RWResult;
62 inline std::size_t convert_rwcount(std::size_t count) {
return count; }
75 throw SystemError(errno,
"cannot open file {}", filename);
93 throw SystemError(errno,
"cannot get file descriptor");
98 int mode = S_IRUSR | S_IWUSR;
99 #if defined(_WIN32) && !defined(__MINGW32__) 106 throw SystemError(errno,
"cannot open file {}", path);
132 DWORD size_upper = 0;
133 HANDLE handle =
reinterpret_cast<HANDLE>(_get_osfhandle(fd_));
134 DWORD size_lower =
FMT_SYSTEM(GetFileSize(handle, &size_upper));
135 if (size_lower == INVALID_FILE_SIZE) {
136 DWORD error = GetLastError();
137 if (error != NO_ERROR)
138 throw WindowsError(GetLastError(),
"cannot get file size");
141 return (long_size <<
sizeof(DWORD) * CHAR_BIT) | size_lower;
143 typedef struct stat Stat;
144 Stat file_stat = Stat();
146 throw SystemError(errno,
"cannot get file attributes");
148 "return type of File::size is not large enough");
149 return file_stat.st_size;
174 throw SystemError(errno,
"cannot duplicate file descriptor {}", fd);
183 "cannot duplicate file descriptor {} to {}", fd_, fd);
202 enum { DEFAULT_CAPACITY = 65536 };
213 read_end =
File(fds[0]);
214 write_end =
File(fds[1]);
221 throw SystemError(errno,
"cannot associate stream with file descriptor");
231 return si.dwPageSize;
235 throw SystemError(errno,
"cannot get memory page size");
~BufferedFile() FMT_NOEXCEPT
FMT_FUNC void write(std::ostream &os, Writer &w)
FMT_GCC_EXTENSION typedef unsigned long long ULongLong
GLsizei const GLchar *const * path
const Char * c_str() const
FMT_FUNC void report_system_error(int error_code, fmt::StringRef message) FMT_NOEXCEPT
#define FMT_RETRY_VAL(result, expression, error_result)
std::size_t read(void *buffer, std::size_t count)
#define FMT_RETRY(result, expression)
GLuint GLuint GLsizei count
MakeUnsigned< Int >::Type to_unsigned(Int value)
std::size_t write(const void *buffer, std::size_t count)
BufferedFile fdopen(const char *mode)
BufferedFile() FMT_NOEXCEPT
static void pipe(File &read_end, File &write_end)
#define FMT_POSIX_CALL(call)
FMT_GCC_EXTENSION typedef long long LongLong
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC