home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2510 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.0 KB  |  29 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import win32file
  5. import win32api
  6. import win32con
  7. import os
  8.  
  9. def SimpleFileDemo():
  10.     testName = os.path.join(win32api.GetTempPath(), 'win32file_demo_test_file')
  11.     if os.path.exists(testName):
  12.         os.unlink(testName)
  13.     
  14.     handle = win32file.CreateFile(testName, win32file.GENERIC_WRITE, 0, None, win32con.CREATE_NEW, 0, None)
  15.     test_data = 'Hello\x00there'
  16.     win32file.WriteFile(handle, test_data)
  17.     handle.Close()
  18.     handle = win32file.CreateFile(testName, win32file.GENERIC_READ, 0, None, win32con.OPEN_EXISTING, 0, None)
  19.     (rc, data) = win32file.ReadFile(handle, 1024)
  20.     handle.Close()
  21.     if data == test_data:
  22.         print 'Successfully wrote and read a file'
  23.     
  24.     os.unlink(testName)
  25.  
  26. if __name__ == '__main__':
  27.     SimpleFileDemo()
  28.  
  29.