File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313
1414# only run if the current system support large files
15- f = open (test_support .TESTFN , 'w ' )
15+ f = open (test_support .TESTFN , 'wb ' )
1616try :
1717 # 2**31 == 2147483648
1818 f .seek (2147483649L )
@@ -58,21 +58,21 @@ def expect(got_this, expect_this):
5858
5959if test_support .verbose :
6060 print 'create large file via seek (may be sparse file) ...'
61- f = open (name , 'w ' )
61+ f = open (name , 'wb ' )
6262f .seek (size )
6363f .write ('a' )
6464f .flush ()
65- expect (os .fstat (f .fileno ())[stat .ST_SIZE ], size + 1 )
6665if test_support .verbose :
6766 print 'check file size with os.fstat'
67+ expect (os .fstat (f .fileno ())[stat .ST_SIZE ], size + 1 )
6868f .close ()
6969if test_support .verbose :
7070 print 'check file size with os.stat'
7171expect (os .stat (name )[stat .ST_SIZE ], size + 1 )
7272
7373if test_support .verbose :
7474 print 'play around with seek() and read() with the built largefile'
75- f = open (name , 'r ' )
75+ f = open (name , 'rb ' )
7676expect (f .tell (), 0 )
7777expect (f .read (1 ), '\000 ' )
7878expect (f .tell (), 1 )
Original file line number Diff line number Diff line change @@ -155,6 +155,12 @@ Tests
155155
156156Windows
157157
158+ - Large file support is now enabled on Win32 platforms as well as on
159+ Win64. This means that, for example, you can use f.tell() and f.seek()
160+ to manipulate files larger than 2 gigabytes (provided you have enough
161+ disk space, and are using a Windows filesystem that supports large
162+ partitions).
163+
158164- The w9xpopen hack is now used on Windows NT and 2000 too when COMPSPEC
159165 points to command.com (patch from Brian Quinlan).
160166
Original file line number Diff line number Diff line change @@ -264,7 +264,7 @@ extern int lstat(const char *, struct stat *);
264264
265265/* choose the appropriate stat and fstat functions and return structs */
266266#undef STAT
267- #ifdef MS_WIN64
267+ #if defined( MS_WIN64 ) || defined( MS_WIN32 )
268268# define STAT _stati64
269269# define FSTAT _fstati64
270270# define STRUCT_STAT struct _stati64
@@ -3491,7 +3491,7 @@ static PyObject *
34913491posix_lseek (PyObject * self , PyObject * args )
34923492{
34933493 int fd , how ;
3494- #ifdef MS_WIN64
3494+ #if defined( MS_WIN64 ) || defined( MS_WIN32 )
34953495 LONG_LONG pos , res ;
34963496#else
34973497 off_t pos , res ;
@@ -3518,7 +3518,7 @@ posix_lseek(PyObject *self, PyObject *args)
35183518 return NULL ;
35193519
35203520 Py_BEGIN_ALLOW_THREADS
3521- #ifdef MS_WIN64
3521+ #if defined( MS_WIN64 ) || defined( MS_WIN32 )
35223522 res = _lseeki64 (fd , pos , how );
35233523#else
35243524 res = lseek (fd , pos , how );
Original file line number Diff line number Diff line change @@ -367,7 +367,7 @@ file_truncate(PyFileObject *f, PyObject *args)
367367 } else {
368368 Py_BEGIN_ALLOW_THREADS
369369 errno = 0 ;
370- ret = _chsize (fileno (f -> f_fp ), newsize );
370+ ret = _chsize (fileno (f -> f_fp ), ( long ) newsize );
371371 Py_END_ALLOW_THREADS
372372 if (ret != 0 ) goto onioerror ;
373373 }
Original file line number Diff line number Diff line change @@ -313,6 +313,7 @@ typedef int pid_t;
313313# define HAVE_LARGEFILE_SUPPORT
314314#elif defined(MS_WIN32 )
315315# define PLATFORM "win32"
316+ # define HAVE_LARGEFILE_SUPPORT
316317# ifdef _M_ALPHA
317318# define SIZEOF_VOID_P 8
318319# define SIZEOF_TIME_T 8
You can’t perform that action at this time.
0 commit comments