Improve naming consistency

This commit is contained in:
Victor Zverovich
2018-05-19 10:32:53 -07:00
parent fbd5153487
commit b76bb79613
9 changed files with 153 additions and 153 deletions

View File

@@ -97,7 +97,7 @@ int buffered_file::fileno() const {
return fd;
}
File::File(cstring_view path, int oflag) {
file::file(cstring_view path, int oflag) {
int mode = S_IRUSR | S_IWUSR;
#if defined(_WIN32) && !defined(__MINGW32__)
fd_ = -1;
@@ -109,14 +109,14 @@ File::File(cstring_view path, int oflag) {
FMT_THROW(system_error(errno, "cannot open file {}", path.c_str()));
}
File::~File() FMT_NOEXCEPT {
file::~file() FMT_NOEXCEPT {
// Don't retry close in case of EINTR!
// See http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
if (fd_ != -1 && FMT_POSIX_CALL(close(fd_)) != 0)
report_system_error(errno, "cannot close file");
}
void File::close() {
void file::close() {
if (fd_ == -1)
return;
// Don't retry close in case of EINTR!
@@ -127,7 +127,7 @@ void File::close() {
FMT_THROW(system_error(errno, "cannot close file"));
}
long long File::size() const {
long long file::size() const {
#ifdef _WIN32
// Use GetFileSize instead of GetFileSizeEx for the case when _WIN32_WINNT
// is less than 0x0500 as is the case with some default MinGW builds.
@@ -148,12 +148,12 @@ long long File::size() const {
if (FMT_POSIX_CALL(fstat(fd_, &file_stat)) == -1)
FMT_THROW(system_error(errno, "cannot get file attributes"));
static_assert(sizeof(long long) >= sizeof(file_stat.st_size),
"return type of File::size is not large enough");
"return type of file::size is not large enough");
return file_stat.st_size;
#endif
}
std::size_t File::read(void *buffer, std::size_t count) {
std::size_t file::read(void *buffer, std::size_t count) {
RWResult result = 0;
FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count))));
if (result < 0)
@@ -161,7 +161,7 @@ std::size_t File::read(void *buffer, std::size_t count) {
return internal::to_unsigned(result);
}
std::size_t File::write(const void *buffer, std::size_t count) {
std::size_t file::write(const void *buffer, std::size_t count) {
RWResult result = 0;
FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));
if (result < 0)
@@ -169,16 +169,16 @@ std::size_t File::write(const void *buffer, std::size_t count) {
return internal::to_unsigned(result);
}
File File::dup(int fd) {
file file::dup(int fd) {
// Don't retry as dup doesn't return EINTR.
// http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html
int new_fd = FMT_POSIX_CALL(dup(fd));
if (new_fd == -1)
FMT_THROW(system_error(errno, "cannot duplicate file descriptor {}", fd));
return File(new_fd);
return file(new_fd);
}
void File::dup2(int fd) {
void file::dup2(int fd) {
int result = 0;
FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd)));
if (result == -1) {
@@ -187,14 +187,14 @@ void File::dup2(int fd) {
}
}
void File::dup2(int fd, ErrorCode &ec) FMT_NOEXCEPT {
void file::dup2(int fd, error_code &ec) FMT_NOEXCEPT {
int result = 0;
FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd)));
if (result == -1)
ec = ErrorCode(errno);
ec = error_code(errno);
}
void File::pipe(File &read_end, File &write_end) {
void file::pipe(file &read_end, file &write_end) {
// Close the descriptors first to make sure that assignments don't throw
// and there are no leaks.
read_end.close();
@@ -213,11 +213,11 @@ void File::pipe(File &read_end, File &write_end) {
FMT_THROW(system_error(errno, "cannot create pipe"));
// The following assignments don't throw because read_fd and write_fd
// are closed.
read_end = File(fds[0]);
write_end = File(fds[1]);
read_end = file(fds[0]);
write_end = file(fds[1]);
}
buffered_file File::fdopen(const char *mode) {
buffered_file file::fdopen(const char *mode) {
// Don't retry as fdopen doesn't return EINTR.
FILE *f = FMT_POSIX_CALL(fdopen(fd_, mode));
if (!f)