1 #ifndef OSMIUM_UTIL_FILE_HPP 2 #define OSMIUM_UTIL_FILE_HPP 39 #include <system_error> 41 #include <sys/types.h> 52 # define ftruncate _chsize_s 73 auto size = ::_filelengthi64(fd);
75 throw std::system_error(errno, std::system_category(),
"_filelengthi64 failed");
81 if (::fstat(fd, &s) != 0) {
82 throw std::system_error(errno, std::system_category(),
"fstat failed");
84 return size_t(s.st_size);
97 if (::ftruncate(fd, static_cast_with_assert<off_t>(new_size)) != 0) {
98 throw std::system_error(errno, std::system_category(),
"ftruncate failed");
110 return si.dwPageSize;
113 return size_t(::sysconf(_SC_PAGESIZE));
121 #endif // OSMIUM_UTIL_FILE_HPP size_t file_size(int fd)
Definition: file.hpp:69
size_t get_pagesize()
Definition: file.hpp:105
Namespace for everything in the Osmium library.
Definition: assembler.hpp:59
void resize_file(int fd, size_t new_size)
Definition: file.hpp:96