diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-06-14 14:12:19 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-06-14 15:59:47 +0200 |
| commit | 2d85c7e86d893946a4f0e84f57698833c3b79c37 (patch) | |
| tree | d771794cac097e13da7aa3966084917076610d54 /src/win32 | |
| parent | 0c2d0d4b90401088c5c67eea2c4c80588c854ff7 (diff) | |
| download | libgit2-2d85c7e86d893946a4f0e84f57698833c3b79c37.tar.gz | |
posix: remove `p_fallocate` abstraction
By now, we have repeatedly failed to provide a nice
cross-platform implementation of `p_fallocate`. Recent tries to
do that escalated quite fast to a set of different CMake checks,
implementations, fallbacks, etc., which started to look real
awkward to maintain. In fact, `p_fallocate` had only been
introduced in commit 4e3949b73 (tests: test that largefiles can
be read through the tree API, 2019-01-30) to support a test with
large files, but given the maintenance costs it just seems not to
be worht it.
As we have removed the sole user of `p_fallocate` in the previous
commit, let's drop it altogether.
Diffstat (limited to 'src/win32')
| -rw-r--r-- | src/win32/posix_w32.c | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index c082dbacd..91e164348 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -525,58 +525,6 @@ int p_creat(const char *path, mode_t mode) return p_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); } -int p_fallocate(int fd, off_t offset, off_t len) -{ - HANDLE fh = (HANDLE)_get_osfhandle(fd); - LARGE_INTEGER zero, position, oldsize, newsize; - size_t size; - - if (fh == INVALID_HANDLE_VALUE) { - errno = EBADF; - return -1; - } - - if (offset < 0 || len <= 0) { - errno = EINVAL; - return -1; - } - - if (git__add_sizet_overflow(&size, offset, len)) { - errno = EINVAL; - return -1; - } - - zero.u.LowPart = 0; - zero.u.HighPart = 0; - - newsize.u.LowPart = (size & 0xffffffff); - -#if (SIZE_MAX > UINT32_MAX) - newsize.u.HighPart = size >> 32; -#else - newsize.u.HighPart = 0; -#endif - - if (!GetFileSizeEx(fh, &oldsize)) { - set_errno(); - return -1; - } - - /* POSIX emulation: attempting to shrink the file is ignored */ - if (oldsize.QuadPart >= newsize.QuadPart) - return 0; - - if (!SetFilePointerEx(fh, zero, &position, FILE_CURRENT) || - !SetFilePointerEx(fh, newsize, NULL, FILE_BEGIN) || - !SetEndOfFile(fh) || - !SetFilePointerEx(fh, position, 0, FILE_BEGIN)) { - set_errno(); - return -1; - } - - return 0; -} - int p_utimes(const char *path, const struct p_timeval times[2]) { git_win32_path wpath; |
