예제 #1
0
 def ftruncate_win32(fd, size):
     curpos = os.lseek(fd, 0, 1)
     try:
         # move to the position to be truncated
         os.lseek(fd, size, 0)
         # Truncate.  Note that this may grow the file!
         handle = get_osfhandle(fd)
         if not SetEndOfFile(handle):
             raise OSError(GetLastError_saved(), "Could not truncate file")
     finally:
         # we restore the file pointer position in any case
         os.lseek(fd, curpos, 0)
예제 #2
0
def getwinerror(space, code=-1):
    from rpython.rlib.rwin32 import GetLastError_saved, FormatError
    if code == -1:
        code = GetLastError_saved()
    message = FormatError(code)
    return space.newtuple([space.wrap(code), space.wrap(message)])