Skip to main content

A simple module.

Project description

LogicDaemon-py3-win32-symlink-resolve

resolve_win32_symlink

Resolve Windows symlink targets using the Windows API. Unlike os.readlink(), this can resolve both absolute and relative symlinks correctly on Windows, including those that point to UNC paths.

Installation

pip install LogicDaemon-win32-symlink-resolve

Usage

from pathlib import Path
from resolve_win32_symlink import resolve_symlink

# Returns the target Path if it's a symlink, or None if the path is not a valid IO_REPARSE_TAG_SYMLINK.
target_path: Path | None = resolve_symlink(Path(r'C:\path\to\symlink'))

if target_path:
    print(f"Symlink points to: {target_path}")

Important Notes and Limitations

  • Windows Only: This package relies on ctypes bindings for kernel32.dll and Windows-specific DeviceIoControl codes. It is exclusively for Windows environments.
  • Supported Reparse Points: This module specifically resolves symlinks (IO_REPARSE_TAG_SYMLINK). Other types of reparse points, such as directory junctions (IO_REPARSE_TAG_MOUNT_POINT), are not supported and will resolve to None.
  • Path Prefixes: Windows symlink targets often use the NT device prefix \??\ in the raw substitution name. To preserve idiomatic paths, resolve_symlink extracts the cleaner PrintName when available, falling back to the target's SubstituteName only if PrintName is empty.

To build and publish to PyPI, you can run the following commands in your terminal:

# Ensure you have the build tool and twine installed
pip install build twine

# Build the distribution packages
python -m build

# Upload to PyPI (this will ask for credentials)
twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logicdaemon_win32_symlink_resolve-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page