Documentation Archive Developer
Search

ADC Home > Reference Library > Technical Q&As > Carbon > File Management >

PBLockRange with a zero-length range


Q Why do I keep getting the afpRangeOverlap (-5021) error although the file is not ranged-locked?

A The most likely culprit might be that you are doing a range-lock/unlocked-wrapped PBWrite() with a length determined programmatically. If this computed length happens to be zero at a specific offset, then any further attempt to call PBLockRange which would include that offset will return the afpRangeOverlap error.

This is a known bug [2295724] which has yet to be fixed. A valid, now and in the future, workaround is to simply test the computed length against zero and to not call the sequence in that case.

[Nov 22 1999]