# 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)
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'
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)
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).
/* 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
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;
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);
} 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;
}
# 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