.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "libapache2-mod-perl2-2.0.11::docs::api::APR::Finfo 3pm" .TH libapache2-mod-perl2-2.0.11::docs::api::APR::Finfo 3pm "2021-02-22" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" APR::Finfo \- Perl API for APR fileinfo structure .SH "Synopsis" .IX Header "Synopsis" .Vb 3 \& use APR::Finfo (); \& use APR::Const \-compile => qw(FINFO_NORM); \& my $finfo = APR::Finfo::stat("/tmp/test", APR::Const::FINFO_NORM, $pool); \& \& $device = $finfo\->device; # (stat $file)[0] \& $inode = $finfo\->inode; # (stat $file)[1] \& # stat returns an octal number while protection is hex \& $prot = $finfo\->protection; # (stat $file)[2] \& $nlink = $finfo\->nlink; # (stat $file)[3] \& $gid = $finfo\->group; # (stat $file)[4] \& $uid = $finfo\->user; # (stat $file)[5] \& $size = $finfo\->size; # (stat $file)[7] \& $atime = $finfo\->atime; # (stat $file)[8] \& $mtime = $finfo\->mtime; # (stat $file)[9] \& $ctime = $finfo\->ctime; # (stat $file)[10] \& \& $csize = $finfo\->csize; # consumed size: not portable! \& \& $filetype = $finfo\->filetype; # file/dir/socket/etc \& \& $fname = $finfo\->fname; \& $name = $finfo\->name; # in filesystem case: \& \& # valid fields that can be queried \& $valid = $finfo\->valid; .Ve .SH "Description" .IX Header "Description" \&\s-1APR\s0 fileinfo structure provides somewhat similar information to Perl's \&\f(CW\*(C`stat()\*(C'\fR call, but you will want to use this module's \s-1API\s0 to query an already \f(CW\*(C`stat()\*(Aqed\*(C'\fR filehandle to avoid an extra system call or to query attributes specific to \s-1APR\s0 file handles. .PP During the \s-1HTTP\s0 request handlers coming after \&\f(CW\*(C`PerlMapToStorageHandler\*(C'\fR, \&\f(CW\*(C`$r\->finfo\*(C'\fR already contains the cached values from the apr's \f(CW\*(C`stat()\*(C'\fR call. So you don't want to perform it again, but instead get the \f(CW\*(C`ARP::Finfo\*(C'\fR object via: .PP .Vb 1 \& my $finfo = $r\->finfo; .Ve .SH "API" .IX Header "API" \&\f(CW\*(C`APR::Finfo\*(C'\fR provides the following functions and/or methods: .ie n .SS """atime""" .el .SS "\f(CWatime\fP" .IX Subsection "atime" Get the time the file was last accessed: .PP .Vb 1 \& $atime = $finfo\->atime; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $atime ( integer )" 4 .el .IP "return: \f(CW$atime\fR ( integer )" 4 .IX Item "return: $atime ( integer )" .PD Last access time in seconds since the epoch .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[8] .Ve .PP Note that this method may not be reliable on all platforms, most notably Win32 \*(-- \s-1FAT32\s0 filesystems appear to work properly, but \s-1NTFS\s0 filesystems do not. .ie n .SS """csize""" .el .SS "\f(CWcsize\fP" .IX Subsection "csize" Get the storage size consumed by the file .PP .Vb 1 \& $csize = $finfo\->csize; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $csize ( integer )" 4 .el .IP "return: \f(CW$csize\fR ( integer )" 4 .IX Item "return: $csize ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP Chances are that you don't want to use this method, since its functionality is not supported on most platforms (in which case it always returns 0). .ie n .SS """ctime""" .el .SS "\f(CWctime\fP" .IX Subsection "ctime" Get the time the file was last changed .PP .Vb 1 \& $ctime = $finfo\->ctime; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $ctime ( integer )" 4 .el .IP "return: \f(CW$ctime\fR ( integer )" 4 .IX Item "return: $ctime ( integer )" .PD Inode change time in seconds since the epoch .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[10] .Ve .PP The ctime field is non-portable. In particular, you cannot expect it to be a \*(L"creation time\*(R", see \*(L"Files and Filesystems\*(R" in the \&\fIperlport\fR manpage for details. .ie n .SS """device""" .el .SS "\f(CWdevice\fP" .IX Subsection "device" Get the id of the device the file is on. .PP .Vb 1 \& $device = $finfo\->device; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $device ( integer )" 4 .el .IP "return: \f(CW$device\fR ( integer )" 4 .IX Item "return: $device ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[0] .Ve .PP Note that this method is non-portable. It doesn't work on all platforms, most notably Win32. .ie n .SS """filetype""" .el .SS "\f(CWfiletype\fP" .IX Subsection "filetype" Get the type of file. .PP .Vb 1 \& $filetype = $finfo\->filetype; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $filetype ( "":filetype constant"" )" 4 .el .IP "return: \f(CW$filetype\fR ( \f(CW:filetype constant\fR )" 4 .IX Item "return: $filetype ( :filetype constant )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP For example: .PP .Vb 10 \& use APR::Pool; \& use APR::Finfo; \& use APR::Const \-compile => qw(FILETYPE_DIR FILETYPE_REG FINFO_NORM); \& my $pool = APR::Pool\->new(); \& my $finfo = APR::Finfo::stat("/tmp", APR::Const::FINFO_NORM, $pool); \& my $finfo = $finfo\->filetype; \& if ($finfo == APR::Const::FILETYPE_REG) { \& print "regular file"; \& } \& elsif ($finfo == APR::Const::FILETYPE_REG) { \& print "directory"; \& } \& else { \& print "other file"; \& } .Ve .PP Since \fI/tmp\fR is a directory, this will print: .PP .Vb 1 \& directory .Ve .ie n .SS """fname""" .el .SS "\f(CWfname\fP" .IX Subsection "fname" Get the pathname of the file (possibly unrooted) .PP .Vb 1 \& $fname = $finfo\->fname; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $filetype ( string )" 4 .el .IP "return: \f(CW$filetype\fR ( string )" 4 .IX Item "return: $filetype ( string )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """group""" .el .SS "\f(CWgroup\fP" .IX Subsection "group" Get the group id that owns the file: .PP .Vb 1 \& $gid = $finfo\->group; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $gid ( number )" 4 .el .IP "return: \f(CW$gid\fR ( number )" 4 .IX Item "return: $gid ( number )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[5] .Ve .PP Note that this method may not be meaningful on all platforms, most notably Win32. Incorrect results have also been reported on some versions of \s-1OSX.\s0 .ie n .SS """inode""" .el .SS "\f(CWinode\fP" .IX Subsection "inode" Get the inode of the file. .PP .Vb 1 \& $inode = $finfo\->inode; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $inode ( integer )" 4 .el .IP "return: \f(CW$inode\fR ( integer )" 4 .IX Item "return: $inode ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[1] .Ve .PP Note that this method may not be meaningful on all platforms, most notably Win32. .ie n .SS """mtime""" .el .SS "\f(CWmtime\fP" .IX Subsection "mtime" The time the file was last modified .PP .Vb 1 \& $mtime = $finfo\->mtime; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $mtime ( integer )" 4 .el .IP "return: \f(CW$mtime\fR ( integer )" 4 .IX Item "return: $mtime ( integer )" .PD Last modify time in seconds since the epoch .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[9] .Ve .ie n .SS """name""" .el .SS "\f(CWname\fP" .IX Subsection "name" Get the file's name (no path) in filesystem case: .PP .Vb 1 \& $name = $finfo\->name; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $device ( string )" 4 .el .IP "return: \f(CW$device\fR ( string )" 4 .IX Item "return: $device ( string )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .ie n .SS """nlink""" .el .SS "\f(CWnlink\fP" .IX Subsection "nlink" Get the number of hard links to the file. .PP .Vb 1 \& $nlink = $finfo\->nlink; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $nlink ( integer )" 4 .el .IP "return: \f(CW$nlink\fR ( integer )" 4 .IX Item "return: $nlink ( integer )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[3] .Ve .ie n .SS """protection""" .el .SS "\f(CWprotection\fP" .IX Subsection "protection" Get the access permissions of the file. Mimics Unix access rights. .PP .Vb 1 \& $prot = $finfo\->protection; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $prot ( "":fprot constant"" )" 4 .el .IP "return: \f(CW$prot\fR ( \f(CW:fprot constant\fR )" 4 .IX Item "return: $prot ( :fprot constant )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[2] .Ve .PP Note: Perl's stat returns an octal number while mod_perl's \f(CW\*(C`protection\*(C'\fR returns a hex number. .PP See perldoc \-f stat and \s-1APR\s0's file_io for more information on each. .ie n .SS """size""" .el .SS "\f(CWsize\fP" .IX Subsection "size" Get the size of the file .PP .Vb 1 \& $size = $finfo\->size; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $size ( integer )" 4 .el .IP "return: \f(CW$size\fR ( integer )" 4 .IX Item "return: $size ( integer )" .PD Total size of file, in bytes .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[7] .Ve .ie n .SS """stat""" .el .SS "\f(CWstat\fP" .IX Subsection "stat" Get the specified file's stats. .PP .Vb 1 \& $finfo = APR::Finfo::stat($fname, $wanted_fields, $p); .Ve .ie n .IP "arg1: $fname ( string )" 4 .el .IP "arg1: \f(CW$fname\fR ( string )" 4 .IX Item "arg1: $fname ( string )" The path to the file to \f(CW\*(C`stat()\*(C'\fR. .ie n .IP "arg2: $wanted_fields ( "":finfo constant"" )" 4 .el .IP "arg2: \f(CW$wanted_fields\fR ( \f(CW:finfo constant\fR )" 4 .IX Item "arg2: $wanted_fields ( :finfo constant )" The desired fields, as a bitmask flag of \&\f(CW\*(C`APR::FINFO_*\*(C'\fR constants. .Sp Notice that you can also use the constants that already combine several elements in one. For example \&\f(CW\*(C`APR::Const::FINFO_PROT\*(C'\fR asks for all protection bits, \&\f(CW\*(C`APR::Const::FINFO_MIN\*(C'\fR asks for the following fields: type, mtime, ctime, atime, size and \&\f(CW\*(C`APR::Const::FINFO_NORM\*(C'\fR asks for all atomic unix \f(CW\*(C`apr_stat()\*(C'\fR fields (similar to perl's \&\f(CW\*(C`stat()\*(C'\fR). .ie n .IP "arg3: $p ( ""APR::Pool object"" )" 4 .el .IP "arg3: \f(CW$p\fR ( \f(CWAPR::Pool object\fR )" 4 .IX Item "arg3: $p ( APR::Pool object )" the pool to use to allocate the file stat structure. .ie n .IP "ret: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "ret: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "ret: $finfo ( APR::Finfo object )" .PD 0 .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP For example, here is how to get most of the \f(CW\*(C`stat\*(C'\fR fields: .PP .Vb 5 \& use APR::Pool (); \& use APR::Finfo (); \& use APR::Const \-compile => qw(FINFO_NORM); \& my $pool = APR::Pool\->new(); \& my $finfo = APR::Finfo::stat("/tmp/test", APR::Const::FINFO_NORM, $pool); .Ve .ie n .SS """user""" .el .SS "\f(CWuser\fP" .IX Subsection "user" Get the user id that owns the file: .PP .Vb 1 \& $uid = $finfo\->user; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "return: $uid ( number )" 4 .el .IP "return: \f(CW$uid\fR ( number )" 4 .IX Item "return: $uid ( number )" .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .PD .PP This method returns the same value as Perl's: .PP .Vb 1 \& (stat $filename)[4] .Ve .PP Note that this method may not be meaningful on all platforms, most notably Win32. .ie n .SS """valid""" .el .SS "\f(CWvalid\fP" .IX Subsection "valid" The bitmask describing valid fields of this apr_finfo_t structure including all available 'wanted' fields and potentially more .PP .Vb 1 \& $valid = $finfo\->valid; .Ve .ie n .IP "obj: $finfo ( ""APR::Finfo object"" )" 4 .el .IP "obj: \f(CW$finfo\fR ( \f(CWAPR::Finfo object\fR )" 4 .IX Item "obj: $finfo ( APR::Finfo object )" .PD 0 .ie n .IP "arg1: $valid ( bitmask )" 4 .el .IP "arg1: \f(CW$valid\fR ( bitmask )" 4 .IX Item "arg1: $valid ( bitmask )" .PD This bitmask flag should be bit-OR'ed against \f(CW\*(C`:finfo constant\*(C'\fR constants. .IP "since: 2.0.00" 4 .IX Item "since: 2.0.00" .SH "See Also" .IX Header "See Also" mod_perl 2.0 documentation. .SH "Copyright" .IX Header "Copyright" mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. .SH "Authors" .IX Header "Authors" The mod_perl development team and numerous contributors.