diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-08-09 14:59:52 +0200 |
---|---|---|
committer | Stefan Hoffmann <stefan991@gmail.com> | 2014-08-31 15:33:23 +0200 |
commit | 9ee1c3604c0cc8a3ec1bac32fb33e9c0d0887155 (patch) | |
tree | 3abe9a5632adaceb7890bf76e260e671b2d46b2f /src | |
parent | e85fe0957d40080f43cbfcbe9eb8864475325b09 (diff) | |
download | rneovim-9ee1c3604c0cc8a3ec1bac32fb33e9c0d0887155.tar.gz rneovim-9ee1c3604c0cc8a3ec1bac32fb33e9c0d0887155.tar.bz2 rneovim-9ee1c3604c0cc8a3ec1bac32fb33e9c0d0887155.zip |
fileinfo: implement os_fileinfo_blocksize
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/memfile.c | 9 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 82369b739a..be8148c28d 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -123,10 +123,11 @@ memfile_T *mf_open(char_u *fname, int flags) */ FileInfo file_info; if (mfp->mf_fd >= 0 - && os_get_file_info_fd(mfp->mf_fd, &file_info) - && file_info.stat.st_blksize >= MIN_SWAP_PAGE_SIZE - && file_info.stat.st_blksize <= MAX_SWAP_PAGE_SIZE) { - mfp->mf_page_size = file_info.stat.st_blksize; + && os_get_file_info_fd(mfp->mf_fd, &file_info)) { + uint64_t blocksize = os_fileinfo_blocksize(&file_info); + if (blocksize >= MIN_SWAP_PAGE_SIZE && blocksize <= MAX_SWAP_PAGE_SIZE) { + mfp->mf_page_size = blocksize; + } } if (mfp->mf_fd < 0 || (flags & (O_TRUNC|O_EXCL)) diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 70a53edb1c..71e8a55c0e 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -412,6 +412,15 @@ uint64_t os_fileinfo_hardlinks(const FileInfo *file_info) return file_info->stat.st_nlink; } +/// Get the blocksize from a `FileInfo`. +/// +/// @return blocksize in bytes. +uint64_t os_fileinfo_blocksize(const FileInfo *file_info) + FUNC_ATTR_NONNULL_ALL +{ + return file_info->stat.st_blksize; +} + /// Get the `FileID` for a given path /// /// @param path Path to the file. |