cadrumo.adapters.persistence.storage.custody.filesystem_primitives module¶
Identity-anchored directory primitives for profile custody storage.
- class WindowsDirectoryAnchorErrors(cannot_open, cannot_verify, invalid_entry, empty_path)[source]¶
Bases:
objectOperator-facing refusals emitted while anchoring a Windows directory.
- class ProfileCustodyPasswordReadOperation(operation, path)[source]¶
Bases:
objectOne actual filesystem operation in the normal-password read set.
-
path:
Path¶
-
path:
- is_real_directory(path)[source]¶
Return whether
pathis a real directory, never a symlink or reparse point.
- ensure_real_directory(path)[source]¶
Create
pathas a real directory, refusing an existing link or non-directory.
- anchor_directory(stack, path, *, final_access=0)[source]¶
Keep a verified directory identity non-deletable for a path operation.
- ensure_profile_custody_local_directory(path)[source]¶
Create one custody-owned directory while its parent identity is pinned.
The caller supplies a single child of an existing storage root. This is intentionally not a recursive convenience function: recursive path walks reintroduce a check-then-create window on Windows and POSIX alike.
- windows_file_information_type()[source]¶
Return the one Win32 identity structure shared by custody operations.
Built once per process: the structure is a pure layout, and every anchored operation asked for it anew.
- windows_create_file_api()[source]¶
Return configured
CreateFileWbindings for identity-anchored calls.Built once per process and shared. The binding is pure configuration, and every consumer that configures a further function on the returned library sets the same signature, so sharing cannot change a call’s conversion.
The
sys.platform == "win32"block, rather than a guard at the call site or an early return, is what establishes the platform for the Windows API below: it is the only guard shape every checker this project runs narrows on, so those references resolve when the tree is analysed for a platform that does not ship them.
Let the anchors of one operation share the component handles they hold.
An operation such as one capsule scan anchors the same ancestor chain again for every member it inspects – every component of the storage root, then the capsules directory – and each anchor re-opened all of them. Inside this scope an anchor reuses a component that another live anchor already holds with at least the access it needs, and opens only what is missing. A component stays held while ANY anchor relying on it is live, so no read runs under an ancestor that was released; a handle closes when its last user leaves. The scope holds nothing of its own, so nothing outlives the operation. Nested scopes share the outermost session.
- windows_directory_anchor(path, *, final_access=0, errors=WindowsDirectoryAnchorErrors(cannot_open='profile capsule directory cannot be identity-anchored', cannot_verify='profile capsule directory identity cannot be verified', invalid_entry='profile capsule directory must not be a reparse point or non-directory', empty_path='profile capsule directory cannot be identity-anchored'))[source]¶
Lock every real component against reparse and delete substitution.
- Return type:
- Parameters:
path (Path)
final_access (int)
errors (WindowsDirectoryAnchorErrors)
- windows_component_paths(path)[source]¶
Return the path of every component below the anchor, outermost first.
String-joined rather than built as successive
Pathobjects: an anchor walks every component of a deep storage path, and rendering each intermediatePathwas the largest cost of anchoring after the Win32 calls themselves.
- posix_directory_fd(path)[source]¶
Walk an absolute directory a component at a time without following links.
- posix_open_child_directory(parent_fd, name)[source]¶
Open
namebelowparent_fdwithout following links, or raise.
- posix_mkdir_child_directory(parent_fd, name)[source]¶
Create directory
namebelowparent_fdand return its open descriptor.
- is_reparse_metadata(metadata)[source]¶
Return whether
metadatadescribes a reparse-point entry.- Return type:
- Parameters:
metadata (stat_result)