Puppet Function: extlib::dir_clean
- Defined in:
- functions/dir_clean.pp
- Function type:
- Puppet Language
Summary
Take a path and normalise it to its Unix form.Overview
Instead of having to deal with the different separators between Unix and Windows this function instead formats Windows paths a equivalent Unix like path.
$dir is defined as a Variant to support cleaning ‘c:’ which is not a valid Stdlib::Absolutepath
14 15 16 17 18 19 20 |
# File 'functions/dir_clean.pp', line 14
function extlib::dir_clean(Variant[Stdlib::Absolutepath, Pattern[/\A[a-zA-Z]:\z/]] $dir) >> Stdlib::Unixpath {
$dir ? {
Stdlib::Windowspath => $dir.regsubst('^([a-zA-Z]):', '/\\1').regsubst('\\\\', '/', 'G'),
Pattern[/\A[a-z]:\z/] => $dir.regsubst('^([a-zA-Z]):', '/\\1'),
default => $dir,
}
}
|