mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 12:38:33 +00:00
replaced mch_fstat() with os_file_get_info_fd()
This commit is contained in:
@@ -98,7 +98,6 @@
|
|||||||
#define vim_isbreak(c) (breakat_flags[(char_u)(c)])
|
#define vim_isbreak(c) (breakat_flags[(char_u)(c)])
|
||||||
|
|
||||||
# define mch_fopen(n, p) fopen((n), (p))
|
# define mch_fopen(n, p) fopen((n), (p))
|
||||||
# define mch_fstat(n, p) fstat((n), (p))
|
|
||||||
# ifdef STAT_IGNORES_SLASH
|
# ifdef STAT_IGNORES_SLASH
|
||||||
/* On Solaris stat() accepts "file/" as if it was "file". Return -1 if
|
/* On Solaris stat() accepts "file/" as if it was "file". Return -1 if
|
||||||
* the name ends in "/" and it's not a directory. */
|
* the name ends in "/" and it's not a directory. */
|
||||||
|
@@ -46,25 +46,6 @@
|
|||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* Some systems have the page size in statfs.f_bsize, some in stat.st_blksize
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_ST_BLKSIZE
|
|
||||||
# define STATFS stat
|
|
||||||
# define F_BSIZE st_blksize
|
|
||||||
# define fstatfs(fd, buf, len, nul) mch_fstat((fd), (buf))
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_SYS_STATFS_H
|
|
||||||
# include <sys/statfs.h>
|
|
||||||
# define STATFS statfs
|
|
||||||
# define F_BSIZE f_bsize
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* for Amiga Dos 2.0x we use Flush
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MEMFILE_PAGE_SIZE 4096 /* default page size */
|
#define MEMFILE_PAGE_SIZE 4096 /* default page size */
|
||||||
|
|
||||||
static long_u total_mem_used = 0; /* total memory used for memfiles */
|
static long_u total_mem_used = 0; /* total memory used for memfiles */
|
||||||
@@ -125,10 +106,6 @@ memfile_T *mf_open(char_u *fname, int flags)
|
|||||||
{
|
{
|
||||||
memfile_T *mfp;
|
memfile_T *mfp;
|
||||||
off_t size;
|
off_t size;
|
||||||
#if defined(STATFS) && defined(UNIX) && !defined(__QNX__) && !defined(__minix)
|
|
||||||
# define USE_FSTATFS
|
|
||||||
struct STATFS stf;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((mfp = (memfile_T *)alloc((unsigned)sizeof(memfile_T))) == NULL)
|
if ((mfp = (memfile_T *)alloc((unsigned)sizeof(memfile_T))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -157,7 +134,6 @@ memfile_T *mf_open(char_u *fname, int flags)
|
|||||||
mfp->mf_page_size = MEMFILE_PAGE_SIZE;
|
mfp->mf_page_size = MEMFILE_PAGE_SIZE;
|
||||||
mfp->mf_old_key = NULL;
|
mfp->mf_old_key = NULL;
|
||||||
|
|
||||||
#ifdef USE_FSTATFS
|
|
||||||
/*
|
/*
|
||||||
* Try to set the page size equal to the block size of the device.
|
* Try to set the page size equal to the block size of the device.
|
||||||
* Speeds up I/O a lot.
|
* Speeds up I/O a lot.
|
||||||
@@ -165,12 +141,13 @@ memfile_T *mf_open(char_u *fname, int flags)
|
|||||||
* in ml_recover(). The size used here may be wrong, therefore
|
* in ml_recover(). The size used here may be wrong, therefore
|
||||||
* mf_blocknr_max must be rounded up.
|
* mf_blocknr_max must be rounded up.
|
||||||
*/
|
*/
|
||||||
|
FileInfo file_info;
|
||||||
if (mfp->mf_fd >= 0
|
if (mfp->mf_fd >= 0
|
||||||
&& fstatfs(mfp->mf_fd, &stf, sizeof(struct statfs), 0) == 0
|
&& os_get_file_info_fd(mfp->mf_fd, &file_info)
|
||||||
&& stf.F_BSIZE >= MIN_SWAP_PAGE_SIZE
|
&& file_info.stat.st_blksize >= MIN_SWAP_PAGE_SIZE
|
||||||
&& stf.F_BSIZE <= MAX_SWAP_PAGE_SIZE)
|
&& file_info.stat.st_blksize <= MAX_SWAP_PAGE_SIZE) {
|
||||||
mfp->mf_page_size = stf.F_BSIZE;
|
mfp->mf_page_size = file_info.stat.st_blksize;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (mfp->mf_fd < 0 || (flags & (O_TRUNC|O_EXCL))
|
if (mfp->mf_fd < 0 || (flags & (O_TRUNC|O_EXCL))
|
||||||
|| (size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0)
|
|| (size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0)
|
||||||
|
@@ -1511,12 +1511,10 @@ line_read_in:
|
|||||||
* compute the first offset.
|
* compute the first offset.
|
||||||
*/
|
*/
|
||||||
if (state == TS_BINARY) {
|
if (state == TS_BINARY) {
|
||||||
/* Get the tag file size (don't use mch_fstat(), it's not
|
// Get the tag file size.
|
||||||
* portable). */
|
if ((filesize = lseek(fileno(fp), (off_t)0L, SEEK_END)) <= 0) {
|
||||||
if ((filesize = lseek(fileno(fp),
|
|
||||||
(off_t)0L, SEEK_END)) <= 0)
|
|
||||||
state = TS_LINEAR;
|
state = TS_LINEAR;
|
||||||
else {
|
} else {
|
||||||
lseek(fileno(fp), (off_t)0L, SEEK_SET);
|
lseek(fileno(fp), (off_t)0L, SEEK_SET);
|
||||||
|
|
||||||
/* Calculate the first read offset in the file. Start
|
/* Calculate the first read offset in the file. Start
|
||||||
|
Reference in New Issue
Block a user