1 #ifndef OSMIUM_UTIL_FILE_HPP
2 #define OSMIUM_UTIL_FILE_HPP
38 #include <system_error>
40 #include <sys/types.h>
51 # define ftruncate _chsize_s
70 auto size = ::_filelengthi64(fd);
72 throw std::system_error(errno, std::system_category(),
"_filelengthi64 failed");
78 if (::fstat(fd, &s) != 0) {
79 throw std::system_error(errno, std::system_category(),
"fstat failed");
81 return size_t(s.st_size);
94 if (::ftruncate(fd, new_size) != 0) {
95 throw std::system_error(errno, std::system_category(),
"ftruncate failed");
107 return si.dwPageSize;
110 return ::sysconf(_SC_PAGESIZE);
118 #endif // OSMIUM_UTIL_FILE_HPP
size_t file_size(int fd)
Definition: file.hpp:66
size_t get_pagesize()
Definition: file.hpp:102
Namespace for everything in the Osmium library.
Definition: assembler.hpp:55
void resize_file(int fd, size_t new_size)
Definition: file.hpp:93