Beispiel #1
0
def write_zero_fill(file_handle, write_length):
    # Bytearray will be initialized with null bytes as part of constructor.
    # Bytearray는 null 바이트로 초기화
    # Write_length는 쓸 바이트 수
    fill_string = bytearray(write_buf_size)
    assert len(fill_string) == write_buf_size

    # Loop and perform writes of write_buf_size bytes or less.
    # Continue until write_length bytes have been written.
    # There is no need to explicitly move the file pointer while
    # writing. We are writing contiguously.
    
    # write_buf_size 바이트 이하의 쓰기를 반복
    # write_length byte가 작성될 때까지 계속합니다.
    while write_length > 0:
        if write_length >= write_buf_size:
            write_string = fill_string
            write_length -= write_buf_size
        else:
            write_string = fill_string[:write_length]
            write_length = 0

        # Write buffer to file.
        #logger.debug("Write %d bytes", len(write_string))
        #파일에 버퍼작성
        _, bytes_written = WriteFile(file_handle, write_string)
        assert bytes_written == len(write_string)

    FlushFileBuffers(file_handle)
def truncate_file(file_handle):
    SetFilePointer(file_handle, 0, FILE_BEGIN)
    SetEndOfFile(file_handle)
    FlushFileBuffers(file_handle)
Beispiel #3
0
 def _pipe_write(self, buf):
     log("pipe_write: %s", binascii.hexlify(buf))
     WriteFile(self.pipe_handle, buf)
     FlushFileBuffers(self.pipe_handle)
     #SetFilePointer(self.pipe_handle, 0, FILE_BEGIN)
     return len(buf)