summaryrefslogtreecommitdiff
path: root/setuptools/windows_support.py
blob: 8da712439146d3506c9dfc90ccb96487e6ce0474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import ctypes


def hide_file(path):
    """
    Set the hidden attribute on a file or directory.

    From http://stackoverflow.com/questions/19622133/

    `path` must be text.
    """

    SetFileAttributesW = ctypes.windll.kernel32.SetFileAttributesW

    FILE_ATTRIBUTE_HIDDEN = 0x02

    ret = SetFileAttributesW(path, FILE_ATTRIBUTE_HIDDEN)
    if not ret:
        raise ctypes.WinError()