mirror of https://github.com/python/cpython.git
Enable large file support on Win32 systems.
Curious: the MS docs say stati64 etc are supported even on Win95, but Win95 doesn't support a filesystem that allows partitions > 2 Gb. test_largefile: This was opening its test file in text mode. I have no idea how that worked under Win64, but it sure needs binary mode on Win98. BTW, on Win98 test_largefile runs quickly (under a second).
This commit is contained in:
parent
97f4a33e12
commit
6e13a562ae
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
|
|
||||||
# only run if the current system support large files
|
# only run if the current system support large files
|
||||||
f = open(test_support.TESTFN, 'w')
|
f = open(test_support.TESTFN, 'wb')
|
||||||
try:
|
try:
|
||||||
# 2**31 == 2147483648
|
# 2**31 == 2147483648
|
||||||
f.seek(2147483649L)
|
f.seek(2147483649L)
|
||||||
|
@ -58,13 +58,13 @@ def expect(got_this, expect_this):
|
||||||
|
|
||||||
if test_support.verbose:
|
if test_support.verbose:
|
||||||
print 'create large file via seek (may be sparse file) ...'
|
print 'create large file via seek (may be sparse file) ...'
|
||||||
f = open(name, 'w')
|
f = open(name, 'wb')
|
||||||
f.seek(size)
|
f.seek(size)
|
||||||
f.write('a')
|
f.write('a')
|
||||||
f.flush()
|
f.flush()
|
||||||
expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1)
|
|
||||||
if test_support.verbose:
|
if test_support.verbose:
|
||||||
print 'check file size with os.fstat'
|
print 'check file size with os.fstat'
|
||||||
|
expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1)
|
||||||
f.close()
|
f.close()
|
||||||
if test_support.verbose:
|
if test_support.verbose:
|
||||||
print 'check file size with os.stat'
|
print 'check file size with os.stat'
|
||||||
|
@ -72,7 +72,7 @@ def expect(got_this, expect_this):
|
||||||
|
|
||||||
if test_support.verbose:
|
if test_support.verbose:
|
||||||
print 'play around with seek() and read() with the built largefile'
|
print 'play around with seek() and read() with the built largefile'
|
||||||
f = open(name, 'r')
|
f = open(name, 'rb')
|
||||||
expect(f.tell(), 0)
|
expect(f.tell(), 0)
|
||||||
expect(f.read(1), '\000')
|
expect(f.read(1), '\000')
|
||||||
expect(f.tell(), 1)
|
expect(f.tell(), 1)
|
||||||
|
|
|
@ -155,6 +155,12 @@ Tests
|
||||||
|
|
||||||
Windows
|
Windows
|
||||||
|
|
||||||
|
- Large file support is now enabled on Win32 platforms as well as on
|
||||||
|
Win64. This means that, for example, you can use f.tell() and f.seek()
|
||||||
|
to manipulate files larger than 2 gigabytes (provided you have enough
|
||||||
|
disk space, and are using a Windows filesystem that supports large
|
||||||
|
partitions).
|
||||||
|
|
||||||
- The w9xpopen hack is now used on Windows NT and 2000 too when COMPSPEC
|
- The w9xpopen hack is now used on Windows NT and 2000 too when COMPSPEC
|
||||||
points to command.com (patch from Brian Quinlan).
|
points to command.com (patch from Brian Quinlan).
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ extern int lstat(const char *, struct stat *);
|
||||||
|
|
||||||
/* choose the appropriate stat and fstat functions and return structs */
|
/* choose the appropriate stat and fstat functions and return structs */
|
||||||
#undef STAT
|
#undef STAT
|
||||||
#ifdef MS_WIN64
|
#if defined(MS_WIN64) || defined(MS_WIN32)
|
||||||
# define STAT _stati64
|
# define STAT _stati64
|
||||||
# define FSTAT _fstati64
|
# define FSTAT _fstati64
|
||||||
# define STRUCT_STAT struct _stati64
|
# define STRUCT_STAT struct _stati64
|
||||||
|
@ -3491,7 +3491,7 @@ static PyObject *
|
||||||
posix_lseek(PyObject *self, PyObject *args)
|
posix_lseek(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int fd, how;
|
int fd, how;
|
||||||
#ifdef MS_WIN64
|
#if defined(MS_WIN64) || defined(MS_WIN32)
|
||||||
LONG_LONG pos, res;
|
LONG_LONG pos, res;
|
||||||
#else
|
#else
|
||||||
off_t pos, res;
|
off_t pos, res;
|
||||||
|
@ -3518,7 +3518,7 @@ posix_lseek(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
#ifdef MS_WIN64
|
#if defined(MS_WIN64) || defined(MS_WIN32)
|
||||||
res = _lseeki64(fd, pos, how);
|
res = _lseeki64(fd, pos, how);
|
||||||
#else
|
#else
|
||||||
res = lseek(fd, pos, how);
|
res = lseek(fd, pos, how);
|
||||||
|
|
|
@ -367,7 +367,7 @@ file_truncate(PyFileObject *f, PyObject *args)
|
||||||
} else {
|
} else {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ret = _chsize(fileno(f->f_fp), newsize);
|
ret = _chsize(fileno(f->f_fp), (long)newsize);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
if (ret != 0) goto onioerror;
|
if (ret != 0) goto onioerror;
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,6 +313,7 @@ typedef int pid_t;
|
||||||
# define HAVE_LARGEFILE_SUPPORT
|
# define HAVE_LARGEFILE_SUPPORT
|
||||||
#elif defined(MS_WIN32)
|
#elif defined(MS_WIN32)
|
||||||
# define PLATFORM "win32"
|
# define PLATFORM "win32"
|
||||||
|
# define HAVE_LARGEFILE_SUPPORT
|
||||||
# ifdef _M_ALPHA
|
# ifdef _M_ALPHA
|
||||||
# define SIZEOF_VOID_P 8
|
# define SIZEOF_VOID_P 8
|
||||||
# define SIZEOF_TIME_T 8
|
# define SIZEOF_TIME_T 8
|
||||||
|
|
Loading…
Reference in New Issue