Skip to main content

cwdfast

A high-performance Python C extension providing native, cross-platform filesystem operations. Optimized for recursive directory traversal, bulk file moving, and batch renaming with minimal memory overhead.

Features

  • Cross-Platform: Native support for Windows (Wide Char) and POSIX/Linux/macOS (FS-encoded bytes).
  • High Performance: Written in C with direct OS API calls (FindFirstFileW/opendir), bypassing Python-level iteration overhead.
  • Smart Conflict Resolution: Automatically appends counters (e.g., -1, -2) to filenames during moves to prevent overwrites.
  • Safe Traversal: Skips . and .., ignores reparse points (Windows), and safely handles symlinks (POSIX).

Installation & Building

Save the C code as fastfs.c and create a setup.py:

from setuptools import setup, Extension

module = Extension(
    "cwdfast",
    sources=["cwdfast.c"],
)

setup(
    name="cwdfast",
    version="0.0.1",
    description="Native filesystem operations",
    ext_modules=[module],
)

Build and install:

python setup.py build_ext --inplace
# or
pip install .

Usage Examples

import cwdfast

# 1. Find all .txt and .log files, ignoring 'node_modules'
files = cwdfast.find_files(
    start="/path/to/dir",
    extensions=[".txt", ".log"],
    excluded=["node_modules", ".git"]
)

# 2. Remove all empty directories, ignoring '.git'
deleted_count = cwdfast.remove_empty_dirs(
    start="/path/to/dir",
    excluded=[".git"]
)

# 3. Move multiple files to a destination (auto-resolves name conflicts)
moved_count = cwdfast.move_files(
    files=["/src/file1.txt", "/src/file2.txt"],
    dest_dir="/dest/dir"
)

# 4. Add '.gma' extension to files without an extension
# (Skips files named 'WorkshopDecompressor' by default)
renamed_count = cwdfast.add_extension_to_files_without_format(
    start="/path/to/dir",
    excluded=[".git"],
    skip_name="WorkshopDecompressor",  # Default
    new_ext=".gma"                     # Default
)

API Reference

Function Description Returns
find_files(start, extensions, excluded=None) Recursively finds files matching any extension in the list. list[str] of matched paths
remove_empty_dirs(start, excluded=None) Recursively deletes empty directories. int (number of dirs deleted)
move_files(files, dest_dir) Moves an iterable of file paths to dest_dir. Creates unique names on conflict. int (number of files moved)
add_extension_to_files_without_format(start, excluded=None, skip_name=None, new_ext=None) Recursively appends new_ext to files lacking a dot in their name. int (number of files renamed)

Note: All path arguments accept standard Python strings. The extension handles OS-specific path encoding automatically.

Download files

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

Source Distribution

cwdfast-0.0.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distributions

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

cwdfast-0.0.2-cp314-cp314-win_amd64.whl (22.2 kB view details)

Uploaded CPython 3.14Windows x86-64

cwdfast-0.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (21.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

cwdfast-0.0.2-cp314-cp314-macosx_12_0_arm64.whl (19.0 kB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

File details

Details for the file cwdfast-0.0.2.tar.gz.

File metadata

  • Download URL: cwdfast-0.0.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cwdfast-0.0.2.tar.gz
Algorithm Hash digest
SHA256 175e953b0b80db8e9a2653999bbb73d1b373905cc8a0c6b6816b32a83abd1852
MD5 7504a91359afbddd4cdfdcdb5f6f3b40
BLAKE2b-256 e505e659e3303219af305142fb5ed3cbc81cd872060d25a9c5f6c9749188d9f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cwdfast-0.0.2.tar.gz:

Publisher: wheels.yml on Mitra-88/cwdfast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cwdfast-0.0.2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: cwdfast-0.0.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cwdfast-0.0.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 386a69da2bbca5adeb9e089d2866d3c4975ef5e81ed0042f91c538c64dc12446
MD5 7eee39d4283a5f683de1449674934f73
BLAKE2b-256 0a98a478a21c4acd266a01c7d5443dd98c917671139848b0a5663e43ca9f9cf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cwdfast-0.0.2-cp314-cp314-win_amd64.whl:

Publisher: wheels.yml on Mitra-88/cwdfast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cwdfast-0.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cwdfast-0.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 931dd1f00c9ca55b46a5d6cb494947497c354404380ce5cfcf241cbe4489292f
MD5 88a4391f8494553034e8c920c2c4b15d
BLAKE2b-256 c5fd34eb3891feda337fbcfc52e9d3bc26f739a5d4b7183f0703beac2347a3d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cwdfast-0.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Mitra-88/cwdfast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cwdfast-0.0.2-cp314-cp314-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for cwdfast-0.0.2-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 caf485396b4753da6412d669824db5dad13a2ff13559db730aeb03354f8678b5
MD5 223c8309a2a31022747cbd139b47364e
BLAKE2b-256 224109a98ce44f1d6aadffdd500a4d598c5bc31741cda1b10a632cfaf0a44837

See more details on using hashes here.

Provenance

The following attestation bundles were made for cwdfast-0.0.2-cp314-cp314-macosx_12_0_arm64.whl:

Publisher: wheels.yml on Mitra-88/cwdfast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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