App::GitFind::FileStatLs - Provide stat information in ls -l format
NOTICE: This is a copy of File::Stat::Ls with modifications, as found at https://github.com/cxw42/File-Stat-Ls.
use App::GitFind::FileStatLs; my $obj = App::GitFind::FileStatLs->new; my $ls = $obj->ls_stat('/my/file/name.txt'); # E.g., " -r-xr-xr-x 1 root other 4523 Jul 12 09:49 /my/file/name.txt"
In "ls_stat ($fn)":
Never take a class parameter, i.e., cannot be called as App::GitFind::FileStatLs->ls_stat or App::GitFind::FileStatLs->new->ls_stat.
App::GitFind::FileStatLs->ls_stat
App::GitFind::FileStatLs->new->ls_stat
Do not call lstat a second time.
lstat
Change output format
General:
Update documentation
Lazily load Carp
This class contains methods to convert stat elements into ls format. It exports two methods: format_mode and ls_stat. The format_mode is borrowed from Stat::lsMode class by Mark Jason Dominus. The ls_stat will build a string formatted as the output of 'ls -l'.
format_mode
ls_stat
Input variables:
None
Variables used or routines called:
How to use:
my $obj = new App::GitFind::FileStatLs; # or my $obj = App::GitFind::FileStatLs->new; # or
Return: new empty or initialized App::GitFind::FileStatLs object.
This class defines the following common methods, routines, and functions.
The :all tag includes all the methods or sub-rountines defined in this class.
:all
use App::GitFind::FileStatLs qw(:all);
It includes the following sub-routines:
$mode - the third element from stat
my $md = $self->format_mode((stat $fn)[2]);
Return: string with permission bits such as -r-xr-xr-x.
$fn - file name
my $ls = ls_stat($fn); # NOT $self->ls_stat($fn) --- not supported
Return: the ls string such as one of the following:
-r-xr-xr-x 1 root other 4523 Jul 12 09:49 uniq drwxr-xr-x 2 root other 2048 Jul 12 09:50 bin lrwxrwxrwx 1 oracle7 dba 40 Jun 12 2002 linked.pl -> /opt/bin/linked2.pl
The output includes a trailing newline.
$fn - file name for getting stat attributes ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($fn); $typ - what type of object that you want it to return. The default is to return a hash containing filename, longname, and a hash ref with all the element from stat. SFTP - to return a Net::SFTP::Attributes object
my $hr = $self->stat_attr($fn); # get hash ref my %h = $self->stat_attr($fn); # get hash
Return: $hr or %h where the hash elements depend on the type. The default is to get a hash array with the following elements:
$hr
%h
filename - file name longname - the ls_stat string for the file a - the attributes of the file with the following elements: dev,ino,mode,nlink,uid,gid,rdev,size,atime,mtime, ctime,blksize,blocks
If the type is SFTP, then it will only return a Net::SFTP::Attributes object with the following elements:
flags,perm,uid,gid,size,atime,mtime
Data::Describe, Oracle::Loader, CGI::Getopt, File::Xcopy, Oracle::Trigger, Debug::EchoMessage, CGI::Getopt, Dir::ls, etc.
Copyright (c) 2005 Hanming Tu. All rights reserved. Portions Copyright (c) 2019 D3 Engineering, LLC.
This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)
To install App::GitFind, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::GitFind
CPAN shell
perl -MCPAN -e shell install App::GitFind
For more information on module installation, please visit the detailed CPAN module installation guide.