Debian Codegraph @

plyer/platforms/macosx/libs/osx_paths.py

raw symbols SCIP
1 import ctypes
2 import os
3
4
5 def NSIterateSearchPaths(directory):
6 LibraryPath = ("/System/Library/Frameworks/CoreFoundation.framework/"
7 "Versions/A/CoreFoundation")
8 CoreFound = ctypes.cdll.LoadLibrary(LibraryPath)
9 NSStartSearchPathEnumeration = CoreFound.NSStartSearchPathEnumeration
10 NSGetNextSearchPathEnumeration = CoreFound.NSGetNextSearchPathEnumeration
11 PATH_MAX = os.pathconf('/', os.pathconf_names['PC_PATH_MAX'])
12 PATH_ENCODING = 'utf8'
13 path_buffer = ctypes.create_string_buffer(PATH_MAX)
14 # paths = [] <- fixme, possible list of paths in directory
15 state = NSStartSearchPathEnumeration(directory, 1)
16 while True:
17 state = NSGetNextSearchPathEnumeration(state, path_buffer)
18 if state == 0:
19 break
20 path = os.path.expanduser(path_buffer.value.decode(PATH_ENCODING))
21 return path