summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-06 00:32:15 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-06 00:32:15 (GMT)
commit6e13a562ae01a962612ca76f9afcc7211240236e (patch)
tree272a23269db39f82d12388554cac8497f2dc4bab
parent97f4a33e125dc14c72070bbf38f723aaa26b9df7 (diff)
downloadcpython-6e13a562ae01a962612ca76f9afcc7211240236e.zip
cpython-6e13a562ae01a962612ca76f9afcc7211240236e.tar.gz
cpython-6e13a562ae01a962612ca76f9afcc7211240236e.tar.bz2
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).
-rw-r--r--Lib/test/test_largefile.py8
-rw-r--r--Misc/NEWS6
-rw-r--r--Modules/posixmodule.c6
-rw-r--r--Objects/fileobject.c2
-rw-r--r--PC/pyconfig.h1
5 files changed, 15 insertions, 8 deletions
diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py
index 54fd274..3f3b8f1 100644
--- a/Lib/test/test_largefile.py
+++ b/Lib/test/test_largefile.py
@@ -12,7 +12,7 @@ import os, struct, stat, sys
# only run if the current system support large files
-f = open(test_support.TESTFN, 'w')
+f = open(test_support.TESTFN, 'wb')
try:
# 2**31 == 2147483648
f.seek(2147483649L)
@@ -58,13 +58,13 @@ def expect(got_this, expect_this):
if test_support.verbose:
print 'create large file via seek (may be sparse file) ...'
-f = open(name, 'w')
+f = open(name, 'wb')
f.seek(size)
f.write('a')
f.flush()
-expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1)
if test_support.verbose:
print 'check file size with os.fstat'
+expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1)
f.close()
if test_support.verbose:
print 'check file size with os.stat'
@@ -72,7 +72,7 @@ expect(os.stat(name)[stat.ST_SIZE], size+1)
if test_support.verbose:
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.read(1), '\000')
expect(f.tell(), 1)
diff --git a/Misc/NEWS b/Misc/NEWS
index 50ec64f..3fa2cb6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -155,6 +155,12 @@ Tests
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
points to command.com (patch from Brian Quinlan).
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 5f6f21d..0b4b765 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -264,7 +264,7 @@ extern int lstat(const char *, struct stat *);
/* choose the appropriate stat and fstat functions and return structs */
#undef STAT
-#ifdef MS_WIN64
+#if defined(MS_WIN64) || defined(MS_WIN32)
# define STAT _stati64
# define FSTAT _fstati64
# define STRUCT_STAT struct _stati64
@@ -3491,7 +3491,7 @@ static PyObject *
posix_lseek(PyObject *self, PyObject *args)
{
int fd, how;
-#ifdef MS_WIN64
+#if defined(MS_WIN64) || defined(MS_WIN32)
LONG_LONG pos, res;
#else
off_t pos, res;
@@ -3518,7 +3518,7 @@ posix_lseek(PyObject *self, PyObject *args)
return NULL;
Py_BEGIN_ALLOW_THREADS
-#ifdef MS_WIN64
+#if defined(MS_WIN64) || defined(MS_WIN32)
res = _lseeki64(fd, pos, how);
#else
res = lseek(fd, pos, how);
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index f592e7a..5909e99 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -367,7 +367,7 @@ file_truncate(PyFileObject *f, PyObject *args)
} else {
Py_BEGIN_ALLOW_THREADS
errno = 0;
- ret = _chsize(fileno(f->f_fp), newsize);
+ ret = _chsize(fileno(f->f_fp), (long)newsize);
Py_END_ALLOW_THREADS
if (ret != 0) goto onioerror;
}
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index f287605..370b518 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -313,6 +313,7 @@ typedef int pid_t;
# define HAVE_LARGEFILE_SUPPORT
#elif defined(MS_WIN32)
# define PLATFORM "win32"
+# define HAVE_LARGEFILE_SUPPORT
# ifdef _M_ALPHA
# define SIZEOF_VOID_P 8
# define SIZEOF_TIME_T 8