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.

windows_support.py 714B

1 year ago
1234567891011121314151617181920212223242526272829
  1. import platform
  2. import ctypes
  3. def windows_only(func):
  4. if platform.system() != 'Windows':
  5. return lambda *args, **kwargs: None
  6. return func
  7. @windows_only
  8. def hide_file(path):
  9. """
  10. Set the hidden attribute on a file or directory.
  11. From http://stackoverflow.com/questions/19622133/
  12. `path` must be text.
  13. """
  14. __import__('ctypes.wintypes')
  15. SetFileAttributes = ctypes.windll.kernel32.SetFileAttributesW
  16. SetFileAttributes.argtypes = ctypes.wintypes.LPWSTR, ctypes.wintypes.DWORD
  17. SetFileAttributes.restype = ctypes.wintypes.BOOL
  18. FILE_ATTRIBUTE_HIDDEN = 0x02
  19. ret = SetFileAttributes(path, FILE_ATTRIBUTE_HIDDEN)
  20. if not ret:
  21. raise ctypes.WinError()