1 import sys, os, errno, platform
7 if not hasattr(os, 'SEEK_DATA'):
8 # Not available on python 2, or on darwin python 3
9 # Also Darwin swaps SEEK_DATA/SEEK_HOLE definitions
10 if platform.system() == "Darwin":
13 SEEK_DATA = 3 # Valid on Linux, FreeBSD, Solaris
15 SEEK_DATA = os.SEEK_DATA
17 # Even if os supports SEEK_DATA or SEEK_HOLE,
18 # the file system may not, in which case it would report
19 # current and eof positions respectively.
20 # Therefore work with an empty file,
21 # ensuring SEEK_DATA returns ENXIO (no more data)
23 fd = os.open(sys.argv[1], os.O_RDONLY)
28 data = os.lseek(fd, 0, SEEK_DATA)
30 if e.errno == errno.ENXIO: