internal package
Foswiki::Configure::FileUtil internal package
Foswiki::Configure::FileUtil Basic file utilities used by Configure and admin scripts
Returns NFC normalized unicode characters
StaticMethod
findFileOnTree($dir, $pattern, $reject) →> $fullpath This is used by checkers and bootstrap to see if there are any ",v" rcs files in the Store.
Example:
findFileOnTree( $Foswiki::cfg{DataDir}, qr/,v$/, qr/,pfv$/ );
SMELL: We could use File::Find as a CPAN solution, however in this case really only need to find the first occurance, we have no need for the full list, just whether or not any exist. File::Find returns the complete list of matching files.
StaticMethod
findFileOnPath($filename) →> $fullpath $filename may be a simple file name e.g. Example.pm or may be a /-separated path e.g. Net/Util or a class path e.g. Net::Util
Note that a terminating .pm is required to find a perl module.
StaticMethod
lscFileName() → $localsite_cfg_path StaticMethod
findPackages( $pattern ) → @list Finds all packages that match the pattern in @INC
$pattern
is a wildcard expression that matches classes e.g. Foswiki::Plugins::*Plugin. * is the only wildcard supported.
Return a list of package names.
StaticMethod
checkCanCreateFile($path) → $report checkTreePerms
.
Returns a message if the check fails or undef if the check passed.
StaticMethod
checkTreePerms($path, $perms, %options) → \%report Perform a recursive check of the specified path. No failures will return undef, otherwise a string report is generated.
$perms is a string of permissions to check:
Basic checks:filter
is a regular expression. Files matching the regex if present will not be checked. This is used to skip hidden files and those with different permission requirements.
maxFileCount
- limit on number of files checked
maxFileErrors
- limit on number of fileError messages generated Default is 10
maxExcessPerms
- limit on number of excessPerms messages generated Default is 10
maxMissingFile
- limit on number of missing file messages generated Default is 10
In addition to the basic and enhanced checks specified in the $perms string, directories are always checked to determine if they have the 'x' permission.
Note that the enhanced checks are important especially on hosted sites. In some environments, the Foswiki perl scripts run under a different user/group than the web server. Basic checks will pass, but the server may still be unable to access the file. The enhanced checks will detect this condition.
StaticMethod
checkGNUProgram($prog, $reporter, $reqVersion ) Check for the availability of a GNU program.
If $reqVersion is provided, (Simple decimmal number) then a warning is issued if older version is detected.
Since Windows (without Cygwin) makes it hard to capture stderr ('2>&1' works only on Win2000 or higher), and Windows will usually have GNU tools in any case (installed for Foswiki since there's no built-in diff, grep, patch, etc), we only check for these tools on Unix/Linux and Cygwin.
Errors are reported by calling ERROR and/or WARN on $reporter
StaticMethod
copytree($from, $to) → @errors Copy a directory tree from one place to another. Errors are reported in @errors, empty if it succeeds. A partial copy may happen if the copy fails mid-way.
StaticMethod
listDir($dir, [$dflag], [$path] ) If $path is used internally for the recursive directory list. It is appended to the Directory. The list of files in @names is relative to the $dir directory. Subroutine called recursively for each subdirectory encountered.
StaticMethod
createArchive($name, $dir, $delete ) StaticMethod
unpackArchive($archive [,$dir] ) → ( $dir, $err ) Errors are reported by returnng a non-null $err
StaticMethod
getPerlLocation( ) Optional parameter is file used to retrieve the shebang. If not specified, defaults to the configure script
StaticMethod
rewriteShebang($file, $newShebang, $taint ) Rewrite the #! (shebang) line of the target script with the specified script name. Clear any taint flag by default, or set it if $taint is true.
This is used in 2 places: - The Package installer - used when installing extensions - In tools/rewriteshebang.pl
StaticMethod
canNfcFilenames($testdir)