Skip to content

Commit

Permalink
GA
Browse files Browse the repository at this point in the history
  • Loading branch information
FI-Mihej committed Apr 1, 2024
1 parent e2c0425 commit 4ec258d
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 42 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/test_app_dir_path_finder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: [ master ]

jobs:
test_wheels__macos_x64__cpython:
name: Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
macos_x64__cpython:
name: macos_x64__cpython. Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -36,8 +36,8 @@ jobs:
python -m pip install --upgrade cengal_light[cengal__file_system__app_fs_structure__app_dir_path]
python ./cengal/file_system/app_fs_structure/app_dir_path/versions/v_0/development/print_app_dirs.py
test_wheels__macos_arm64__cpython:
name: Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
macos_arm64__cpython:
name: macos_arm64__cpython. Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -121,8 +121,8 @@ jobs:
# python -m pip install --upgrade cengal_light[cengal__file_system__app_fs_structure__app_dir_path]
# python ./cengal/file_system/app_fs_structure/app_dir_path/versions/v_0/development/print_app_dirs.py

test_wheels__windows_2019_x64__cpython:
name: Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
windows_2019_x64__cpython:
name: windows_2019_x64__cpython. Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -182,8 +182,8 @@ jobs:
# python ./cengal/file_system/app_fs_structure/app_dir_path/versions/v_0/development/print_app_dirs.py
# shell: cmd

test_wheels__windows_2022_x64__cpython:
name: Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
windows_2022_x64__cpython:
name: windows_2022_x64__cpython. Test App Dir Path Finder on ${{ matrix.os }} for CPython ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -213,8 +213,8 @@ jobs:
python ./cengal/file_system/app_fs_structure/app_dir_path/versions/v_0/development/print_app_dirs.py
shell: cmd

test_wheels__linux_manylinux2014_x86_64__cpython:
name: Test on Docker ${{ matrix.image }} for CPython ${{ matrix.python-version }}
manylinux2014_x86_64__cpython:
name: manylinux2014_x86_64__cpython. Test on Docker ${{ matrix.image }} for CPython ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -281,8 +281,8 @@ jobs:
# python -m pip install --upgrade cengal_light[cengal__file_system__app_fs_structure__app_dir_path]
# python ./cengal/file_system/app_fs_structure/app_dir_path/versions/v_0/development/print_app_dirs.py

test_wheels__linux_musllinux_1_1_x86_64__cpython:
name: Test on Docker ${{ matrix.image }} for CPython ${{ matrix.python-version }}
musllinux_1_1_x86_64__cpython:
name: musllinux_1_1_x86_64__cpython. Test on Docker ${{ matrix.image }} for CPython ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -317,8 +317,8 @@ jobs:
python -m pip install --upgrade cengal_light[cengal__file_system__app_fs_structure__app_dir_path]
python ./cengal/file_system/app_fs_structure/app_dir_path/versions/v_0/development/print_app_dirs.py
test_wheels__linux_musllinux_1_2_x86_64__cpython:
name: Test on Docker ${{ matrix.image }} for CPython ${{ matrix.python-version }}
musllinux_1_2_x86_64__cpython:
name: musllinux_1_2_x86_64__cpython. Test on Docker ${{ matrix.image }} for CPython ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,78 @@
from cengal.system import OS_TYPE

if 'Darwin' == OS_TYPE:
from Foundation import NSSearchPathForDirectoriesInDomains
from Foundation import NSDocumentDirectory, NSUserDomainMask

def get_documents_directory():
# Perform the search
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)
if paths:
# Typically, you're interested in the first result
return paths[0]
else:
return None

# Example usage
documents_path = get_documents_directory()
print("Documents Directory:", documents_path)

def get_caches_directory():
# Perform the search
paths = NSSearchPathForDirectoriesInDomains(13, 1, True)
if paths:
# Typically, you're interested in the first result
return paths[0]
else:
return None

# Example usage
caches_path = get_caches_directory()
print("Caches Directory:", caches_path)
def main():
from Foundation import NSSearchPathForDirectoriesInDomains
from Foundation import NSDocumentDirectory, NSUserDomainMask

def get_documents_directory():
# Perform the search
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)
if paths:
# Typically, you're interested in the first result
return paths[0]
else:
return None

# Example usage
documents_path = get_documents_directory()
print("Documents Directory:", documents_path)

def get_caches_directory():
# Perform the search
paths = NSSearchPathForDirectoriesInDomains(13, 1, True)
if paths:
# Typically, you're interested in the first result
return paths[0]
else:
return None

# Example usage
caches_path = get_caches_directory()
print("Caches Directory:", caches_path)
elif 'Windows' == OS_TYPE:
def main():
from ctypes import POINTER, byref, c_wchar_p
from cengal.ctypes_tools.types import GUID
from cengal.ctypes_tools.tools import cwfunc_def
from ctypes import POINTER, byref, windll, WinError
from ctypes.wintypes import HRESULT, DWORD, HANDLE
from ctypes import c_wchar_p
from uuid import UUID
from typing import Union, Sequence, Any

# Assuming cwfunc_def is defined as before and shell32 is loaded appropriately
# Also assuming GUID is defined correctly elsewhere, for example:
# GUID = c GUID structure definition

# Function declaration using your cwfunc_def helper
SHGetKnownFolderPath = cwfunc_def(
windll.shell32,
'SHGetKnownFolderPath',
(POINTER(GUID), DWORD, HANDLE, POINTER(POINTER(c_wchar_p))),
HRESULT
)

def get_known_folder_path(folder_id):
# Convert string representation of the GUID to a GUID object
folder_id_guid = UUID(folder_id).bytes_le
path_ptr = POINTER(c_wchar_p)()
hresult = SHGetKnownFolderPath(byref(GUID(folder_id_guid)), 0, None, byref(path_ptr))
if hresult != 0:
raise WinError(hresult)
try:
# Convert the path to a Python string and return it
return path_ptr.value
finally:
# Here, you should free the memory allocated by SHGetKnownFolderPath
# Use CoTaskMemFree, as the documentation specifies
windll.ole32.CoTaskMemFree(path_ptr)

# Example usage
# Use the GUID for the folder you're interested in, for example, the Documents folder
folder_id = 'FDD39AD0-238F-46AF-ADB4-6C85480369C7'
path = get_known_folder_path(folder_id)
print(f'Path: {path}')
else:
from cengal.file_system.app_fs_structure.app_dir_path import AppDirectoryType, AppDirPath

Expand Down

0 comments on commit 4ec258d

Please sign in to comment.