README

NAME

path::utils - low-level path introspection utility functions

SYNOPSIS

use path-utils;  # export all subs

use path-utils <path-exists>;  # only export sub path-exists

say path-exists($filename);  0 or 1

DESCRIPTION

path-utils provides a number of low-level path introspection utility functions for those cases where you're interested in performance, rather than functionality.

All subroutines take a (native) string as the only argument.

Note that these functions only return native int and native num values, which can be used in conditions without any problems, just don't expect them to be upgraded to Bool values.

Also note that all functions (except path-exists) expect the path to exist. An exception will be thrown if the path does not exist. The reason for this is that in situations where you are already sure a path exists, there is no point checking for its existence again if you e.g. would like to know its size.

By default all utility functions are exported. But you can limit this to the functions you actually need by specifying the names in the use statement.

EXPORTED SUBROUTINES

path-exists

Returns 1 if paths exists, 0 if not.

path-is-directory

Returns 1 if path is a directory, 0 if not.

path-is-regular-file(str $path) {

Returns 1 if path is a regular file, 0 if not.

path-is-device(str $path) {

Returns 1 if path is a device, 0 if not.

path-is-symbolic-link(str $path) {

Returns 1 if path is a symbolic link, 0 if not.

path-created(str $path) {

Returns number of seconds since epoch as a num when path was created.

path-accessed(str $path) {

Returns number of seconds since epoch as a num when path was last accessed.

path-modified(str $path) {

Returns number of seconds since epoch as a num when path was last modified.

path-meta-modified(str $path) {

Returns number of seconds since epoch as a num when the meta information of the path was last modified.

path-uid(str $path) {

Returns the numeric user id of the path.

path-gid(str $path) {

Returns the numeric group id of the path.

path-inode(str $path) {

Returns the inode of the path.

path-device-number(str $path) {

Returns the device number of the filesystem on which the path resides.

path-mode(str $path) {

Returns the numeric unix-style mode.

path-hard-links(str $path) {

Returns the number of hard links to the path.

path-filesize(str $path) {

Returns the size of the path in bytes.

path-block-size(str $path) {

Returns the preferred I/O size in bytes for interacting wuth the path.

path-blocks(str $path) {

Returns the number of filesystem blocks allocated for this path.

AUTHOR

Elizabeth Mattijsen [email protected]

Source can be located at: https://github.com/lizmat/path-utils . Comments and Pull Requests are welcome.

If you like this module, or what Iā€™m doing more generally, committing to a small sponsorship would mean a great deal to me!

COPYRIGHT AND LICENSE

Copyright 2022 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

path-utils v0.0.1

low-level path introspection utility functions

Authors

  • Elizabeth Mattijsen

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • path-utils

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.