mmap resizing macosx unix

D

David Pratt

Hi. I have been experimenting with mmap recently. I determined how to
read and write properly from it and so search and replace on large
files. The problem I am having is with replaces that are larger than
the mmap. In this instance I need to

* rewind
* resize the mmap to accomodate the text
* move some part of the text to a new location on the mmap so the new
text does not overwrite the old
* write the replacement text

When I try to use resize it gives me the following error;

SystemError: mmap: resizing not available--no mremap()

I pass size to mmap to begin with based on my filesize

size = os.path.getsize(filename)

m = mmap.mmap(f.fileno(), size)

I am attempting to give it new size by doing:

m.resize(size + size_diff)

size_diff is difference between original and what will be new file
size after the insertion.

Can someone provide some hint on resizing or its this a python bug?
Many thanks

Regards
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top