Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CopyFileEx.py 1.2KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import win32api
  2. import win32file
  3. def ProgressRoutine(
  4. TotalFileSize,
  5. TotalBytesTransferred,
  6. StreamSize,
  7. StreamBytesTransferred,
  8. StreamNumber,
  9. CallbackReason,
  10. SourceFile,
  11. DestinationFile,
  12. Data,
  13. ):
  14. print(Data)
  15. print(
  16. TotalFileSize,
  17. TotalBytesTransferred,
  18. StreamSize,
  19. StreamBytesTransferred,
  20. StreamNumber,
  21. CallbackReason,
  22. SourceFile,
  23. DestinationFile,
  24. )
  25. ##if TotalBytesTransferred > 100000:
  26. ## return win32file.PROGRESS_STOP
  27. return win32file.PROGRESS_CONTINUE
  28. temp_dir = win32api.GetTempPath()
  29. fsrc = win32api.GetTempFileName(temp_dir, "cfe")[0]
  30. fdst = win32api.GetTempFileName(temp_dir, "cfe")[0]
  31. print(fsrc, fdst)
  32. f = open(fsrc, "w")
  33. f.write("xxxxxxxxxxxxxxxx\n" * 32768)
  34. f.close()
  35. ## add a couple of extra data streams
  36. f = open(fsrc + ":stream_y", "w")
  37. f.write("yyyyyyyyyyyyyyyy\n" * 32768)
  38. f.close()
  39. f = open(fsrc + ":stream_z", "w")
  40. f.write("zzzzzzzzzzzzzzzz\n" * 32768)
  41. f.close()
  42. operation_desc = "Copying " + fsrc + " to " + fdst
  43. win32file.CopyFileEx(
  44. fsrc,
  45. fdst,
  46. ProgressRoutine,
  47. Data=operation_desc,
  48. Cancel=False,
  49. CopyFlags=win32file.COPY_FILE_RESTARTABLE,
  50. Transaction=None,
  51. )