home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_2863 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  1.8 KB  |  37 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from win32com.shell import shell, shellcon
  5. import win32api
  6. import os
  7.  
  8. def testSHFileOperation(file_cnt):
  9.     temp_dir = os.environ['temp']
  10.     orig_fnames = [ win32api.GetTempFileName(temp_dir, 'sfo')[0] for x in range(file_cnt) ]
  11.     new_fnames = [ os.path.join(temp_dir, 'copy of ' + os.path.split(orig_fnames[x])[1]) for x in range(file_cnt) ]
  12.     pFrom = '\x00'.join(orig_fnames)
  13.     pTo = '\x00'.join(new_fnames)
  14.     shell.SHFileOperation((0, shellcon.FO_MOVE, pFrom, pTo, shellcon.FOF_MULTIDESTFILES | shellcon.FOF_NOCONFIRMATION))
  15.     for fname in orig_fnames:
  16.         pass
  17.     
  18.     for fname in new_fnames:
  19.         shell.SHFileOperation((0, shellcon.FO_DELETE, fname, None, shellcon.FOF_NOCONFIRMATION | shellcon.FOF_NOERRORUI))
  20.     
  21.  
  22.  
  23. def testSHNAMEMAPPINGS(file_cnt):
  24.     temp_dir = os.environ['temp']
  25.     orig_fnames = [ win32api.GetTempFileName(temp_dir, 'sfo')[0] for x in range(file_cnt) ]
  26.     new_fnames = [ win32api.GetTempFileName(temp_dir, 'sfo')[0] for x in range(file_cnt) ]
  27.     pFrom = '\x00'.join(orig_fnames)
  28.     pTo = '\x00'.join(new_fnames)
  29.     (rc, banyaborted, NameMappings) = shell.SHFileOperation((0, shellcon.FO_MOVE, pFrom, pTo, shellcon.FOF_MULTIDESTFILES | shellcon.FOF_NOCONFIRMATION | shellcon.FOF_RENAMEONCOLLISION | shellcon.FOF_WANTMAPPINGHANDLE))
  30.     for old_fname, new_fname in NameMappings:
  31.         print 'Old:', old_fname, 'New:', new_fname
  32.     
  33.  
  34. testSHFileOperation(10)
  35. testSHFileOperation(1)
  36. testSHNAMEMAPPINGS(5)
  37.