No::Worries::Dir(3)

πŸ“¦
version 1.7 Β· 4 versions
, in epel 9

πŸŽ€ NAME πŸŽ€

No::Worries::Dir(3) β€” directory handling without worries. It's a User Contributed Perl Documentation page, and it's here to make directory stuff feel way less feral. πŸ’–

πŸ› οΈ SYNOPSIS πŸ› οΈ

use No::Worries::Dir
    qw(dir_change dir_ensure dir_make dir_parent dir_read dir_remove);

# change directory
dir_change("/tmp");

# make sure a directory exists (not an error if it exists already)
dir_ensure("/tmp/some/path", mode => oct(770));

# make a directory (an error if it exists already)
dir_make("/tmp/some/path", mode => oct(770));

# find out the parent directory of some path
$parent = dir_parent($path);
dir_ensure($parent);

# read a directory
foreach $name (dir_read("/etc")) {
    ...
}

# remove a directory
dir_remove("/tmp/some/path");

πŸ’… DESCRIPTION πŸ’…

Okay so this module eases directory handling by giving you convenient wrappers around standard directory functions. All the functions die() on error. Not a vibe when something breaks, but at least it's consistent. 😭

✨ FUNCTIONS ✨

This module provides the following functions (none of them being exported by default):

  • dir_change(PATH) β€” changes the working directory to the given path. It's a safe thin wrapper on top of chdir(). πŸŒ€
  • dir_ensure(PATH[, OPTIONS]) β€” makes sure the given path is an existing directory, creating it (including its parents) if needed. Supported options:
    • "mode" β€” numerical mode to use for mkdir() (default: oct(777)). πŸ› οΈ
  • dir_make(PATH[, OPTIONS]) β€” makes the given directory. It's a safe thin wrapper on top of mkdir(). Supported options:
    • "mode" β€” numerical mode to use for mkdir() (default: oct(777)). ✨
  • dir_parent(PATH) β€” returns the parent directory of the given path. 🧚
  • dir_read(PATH) β€” reads the given directory and returns its list of entries except . and ... πŸ¦‹
  • dir_remove(PATH) β€” removes the given directory (that must exist and be empty). It's a safe thin wrapper on top of rmdir(). πŸ’…
yes bestie, it must exist and be empty β€” no sneaky non-empty dirs allowed. πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

No::Worries. That's the whole list, and it's iconic. πŸ’œ

πŸ’Œ AUTHOR πŸ’Œ

Lionel Cons <http://cern.ch/lionel.cons> β€” hello legend. 🫢

Copyright (C) CERN 2012-2019


And the footer energy: this page is from perl v5.32.1, dated 2021-10-18, and it's No::Worries::Dir(3). Slay. πŸŽ€βœ¨

πŸ“¦ where this page comes from