cengal.file_system.win_fs.path

 1#!/usr/bin/env python
 2# coding=utf-8
 3
 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>
 5# 
 6# Licensed under the Apache License, Version 2.0 (the "License");
 7# you may not use this file except in compliance with the License.
 8# You may obtain a copy of the License at
 9# 
10#     http://www.apache.org/licenses/LICENSE-2.0
11# 
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17import os
18if 'nt' == os.name:
19    import win32console
20    import codecs
21    import ctypes
22    FILE_ATTRIBUTE_HIDDEN = 0x02
23    FILE_ATTRIBUTE_READONLY = 0x01
24    REMOVABLE_ATTRIBUTES = ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY)
25    WIN_UNICODE_PATH_PREFIX = '\\\\?\\'
26    WUPP = WIN_UNICODE_PATH_PREFIX
27    INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
28    FILE_ATTRIBUTE_REPARSE_POINT = 0x00400
29
30
31"""
32Module Docstring
33Docstrings: http://www.python.org/dev/peps/pep-0257/
34"""
35
36__author__ = "ButenkoMS <gtalk@butenkoms.space>"
37__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>"
38__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ]
39__license__ = "Apache License, Version 2.0"
40__version__ = "4.4.1"
41__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>"
42__email__ = "gtalk@butenkoms.space"
43# __status__ = "Prototype"
44__status__ = "Development"
45# __status__ = "Production"
46
47
48_INSTALLING_BUFFER = {
49    'islink': os.path.islink,
50}
51
52
53def islink(path):
54    result = ctypes.windll.kernel32.GetFileAttributesW(path)
55    if result == INVALID_FILE_ATTRIBUTES:
56        raise ctypes.WinError()
57    return bool(result & FILE_ATTRIBUTE_REPARSE_POINT)
58
59
60def install_module():
61    os.path.islink = islink
62
63
64def uninstall_module():
65    os.path.islink = _INSTALLING_BUFFER['islink']
def install_module():
61def install_module():
62    os.path.islink = islink
def uninstall_module():
65def uninstall_module():
66    os.path.islink = _INSTALLING_BUFFER['islink']