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
71 auto size = ::_filelengthi64(fd);
73 throw std::system_error(errno, std::system_category(),
"_filelengthi64 failed");
79 if (::fstat(fd, &s) != 0) {
80 throw std::system_error(errno, std::system_category(),
"fstat failed");
82 return size_t(s.st_size);
95 if (::ftruncate(fd, new_size) != 0) {
96 throw std::system_error(errno, std::system_category(),
"ftruncate failed");
108 return si.dwPageSize;
111 return ::sysconf(_SC_PAGESIZE);
119 #endif // OSMIUM_UTIL_FILE_HPP
size_t file_size(int fd)
Definition: file.hpp:67
size_t get_pagesize()
Definition: file.hpp:103
Namespace for everything in the Osmium library.
Definition: assembler.hpp:55
void resize_file(int fd, size_t new_size)
Definition: file.hpp:94