NAME

App::Briefing::Filesystem - Unicode-safe filesystem access for App::Briefing

VERSION

version 0.006000

DESCRIPTION

Every file access and environment read of App::Briefing goes through this adapter. Paths go in and come out as character strings. POSIX systems use Path::Tiny. Windows uses explicit Win32::LongPath operations, so Unicode and long paths never pass through Perl's ordinary file tests or open, and reads the environment through the wide API. It installs no global filesystem overrides.

An App::Briefing object takes another adapter through its filesystem attribute; it has to provide the methods below.

is_windows

$filesystem->is_windows

True on Windows (MSWin32), where file access goes through Win32::LongPath and the environment is read through the wide API.

decode_path

my $path = $filesystem->decode_path($bytes);

Returns a path as a character string: bytes that are valid UTF-8 are decoded, anything else, including a string that is already decoded, comes back as it is.

environment_value

my $home = $filesystem->environment_value('HOME');

Returns the environment variable as a character string, or undef when it is unset or empty. On Windows the value comes from the process's wide environment, so characters of the ANSI code page, whichever it is, arrive as characters rather than code page bytes. Characters outside that code page are already ? in that environment by the time Perl code runs (seen with Strawberry Perl) and cannot be recovered. Elsewhere, and on Windows when the wide read yields nothing, the %ENV bytes are decoded as UTF-8 and kept as they are when they are not.

join_path

my $file = $filesystem->join_path( $root, '.claude', 'agents' );

Joins path parts. After the first part, empty and undefined parts are skipped, and an absolute part replaces everything before it. The first part is never skipped: if it is empty or undefined, the call dies with Path::Tiny's Path::Tiny paths require defined, positive-length parts unless the next defined, non-empty part is absolute and so replaces it (join_path('', '/abs') returns /abs). Without any part it returns the empty string.

parent

my $directory = $filesystem->parent($file);

Returns the parent directory of a path.

basename

my $name = $filesystem->basename($file);

Returns the last component of a path.

is_absolute

$filesystem->is_absolute($path)

True for an absolute path.

current_dir

my $cwd = $filesystem->current_dir;

Returns the process's current directory as a character string; on Windows it is read with the wide API.

absolute

my $absolute = $filesystem->absolute($path);

Returns the absolute form of a path, relative to the current directory. On POSIX systems . and .. are folded lexically, as in "normalize".

exists

$filesystem->exists($path)

True when the path exists.

is_file

$filesystem->is_file($path)

True for a plain file.

is_dir

$filesystem->is_dir($path)

True for a directory.

$filesystem->is_dangling_symlink($path)

True for a symbolic link whose target does not exist. Always false on Windows.

is_readable_file

$filesystem->is_readable_file($path)

True for a plain file that can be opened for reading.

slurp_utf8

my $text = $filesystem->slurp_utf8($file);

Returns a file's content decoded from UTF-8, with \r\n and \r turned into \n; an empty string when it is not a file or cannot be read.

spew_utf8

$filesystem->spew_utf8( $file, $text );

Writes text to a file as UTF-8, replacing its content. Returns true on success.

make_path

$filesystem->make_path($directory);

Creates a directory and any missing parents. Returns true when the directory exists afterwards.

children

my $names = $filesystem->children($directory);

Returns an array reference of the names in a directory, sorted, without . and ..; empty when the path is not a readable directory.

child_directories

my $directories = $filesystem->child_directories($directory);

Returns an array reference of the paths of a directory's subdirectories, in name order.

walk_files

my $files = $filesystem->walk_files( $root, '.toml' );

Returns an array reference of the paths of every file below $root, at any depth, whose name ends in the suffix. A directory's own files come before those of its subdirectories.

normalize

my $key = $filesystem->normalize($path);

Returns a path for comparison: repeated separators, . and .. folded lexically. On Windows backslashes also become slashes and the result is lower case.

within

$filesystem->within( $file, $root )

True when $file is $root or lies below it, compared after "normalize".

relative

my $relative = $filesystem->relative( $file, $root );

Returns $file relative to $root.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/briefing/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)