mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-27 20:52:14 +01:00
mmap.mmap works differently under windows
This commit is contained in:
parent
8f38f169d5
commit
0fa507a782
@ -1536,8 +1536,10 @@ def http_request(method, url, headers={}, data=None, file=None, timeout=100):
|
||||
import mmap
|
||||
filefd = open(file, 'r')
|
||||
try:
|
||||
data = mmap.mmap(filefd.fileno(), os.path.getsize(file),
|
||||
mmap.MAP_SHARED, mmap.PROT_READ)
|
||||
if sys.platform[:3] != 'win':
|
||||
data = mmap.mmap(filefd.fileno(), os.path.getsize(file), mmap.MAP_SHARED, mmap.PROT_READ)
|
||||
else:
|
||||
data = mmap.mmap(filefd.fileno(), os.path.getsize(file))
|
||||
data = buffer(data)
|
||||
except EnvironmentError, e:
|
||||
if e.errno == 19:
|
||||
|
@ -147,7 +147,10 @@ class Ar:
|
||||
import mmap
|
||||
self.__file = open(self.filename, 'rb')
|
||||
try:
|
||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot=mmap.PROT_READ)
|
||||
if sys.platform[:3] != 'win':
|
||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot=mmap.PROT_READ)
|
||||
else:
|
||||
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
||||
except EnvironmentError, e:
|
||||
if e.errno == 19:
|
||||
print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io'
|
||||
|
@ -17,6 +17,7 @@ import mmap
|
||||
import os
|
||||
import stat
|
||||
import struct
|
||||
import sys
|
||||
|
||||
# format implementation is based on src/copyin.c and src/util.c (see cpio sources)
|
||||
|
||||
@ -139,7 +140,10 @@ class Cpio:
|
||||
if not self.__file:
|
||||
self.__file = open(self.filename, 'rb')
|
||||
try:
|
||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
|
||||
if sys.platform[:3] != 'win':
|
||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
|
||||
else:
|
||||
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
||||
except EnvironmentError, e:
|
||||
if e.errno == 19:
|
||||
print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'
|
||||
|
Loading…
x
Reference in New Issue
Block a user