Skip to content

Commit 2a8efe2

Browse files
committed
Simplify the implementation
1 parent 9a0d10f commit 2a8efe2

1 file changed

Lines changed: 1 addition & 23 deletions

File tree

Modules/posixmodule.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11421,17 +11421,6 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
1142111421
Py_BEGIN_ALLOW_THREADS
1142211422
_Py_BEGIN_SUPPRESS_IPH
1142311423
#ifdef MS_WINDOWS
11424-
switch (how) {
11425-
case SEEK_SET:
11426-
how = FILE_BEGIN;
11427-
break;
11428-
case SEEK_CUR:
11429-
how = FILE_CURRENT;
11430-
break;
11431-
case SEEK_END:
11432-
how = FILE_END;
11433-
break;
11434-
}
1143511424
HANDLE h = (HANDLE)_get_osfhandle(fd);
1143611425
if (h == INVALID_HANDLE_VALUE) {
1143711426
result = -1;
@@ -11444,25 +11433,14 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
1144411433
}
1144511434
}
1144611435
if (result >= 0) {
11447-
LARGE_INTEGER distance, newdistance;
11448-
distance.QuadPart = position;
11449-
if (SetFilePointerEx(h, distance, &newdistance, how)) {
11450-
result = newdistance.QuadPart;
11451-
} else {
11452-
result = -1;
11453-
}
11436+
result = _lseeki64(fd, position, how);
1145411437
}
1145511438
#else
1145611439
result = lseek(fd, position, how);
1145711440
#endif
1145811441
_Py_END_SUPPRESS_IPH
1145911442
Py_END_ALLOW_THREADS
1146011443
if (result < 0) {
11461-
#ifdef MS_WINDOWS
11462-
if (errno == 0) {
11463-
errno = winerror_to_errno(GetLastError());
11464-
}
11465-
#endif
1146611444
posix_error();
1146711445
}
1146811446

0 commit comments

Comments
 (0)