Stas Bekman wrote:
Geoff,

APR::Finfo::stat() doesn't do what C API does. The C API populates finfo for the file passed in the argument. The current perl API doesn't do that. It populates only $r->finfo, passed as an argument, which may not exist at all.

So it needs to be reworked to create that structure, pass it to apr_stat and return it to the user, not pass it as an argument. Unless you want to work on this by yourself, I'll adjust it shortly.

Let me know if I have missed something.

I've implemented it, please take a look at the adjusted test using the fixed stat API:


Index: t/response/TestAPR/finfo.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestAPR/finfo.pm,v
retrieving revision 1.10
diff -u -r1.10 finfo.pm
--- t/response/TestAPR/finfo.pm 3 May 2004 12:54:08 -0000       1.10
+++ t/response/TestAPR/finfo.pm 22 May 2004 01:04:08 -0000
@@ -44,16 +44,13 @@
     }

     my $file = $r->server_root_relative(catfile qw(htdocs index.html));
+    # populate the finfo struct first
+    my $finfo = APR::Finfo::stat($file, APR::FINFO_NORM, $r->pool);

-    # stat tests
-    {
-        # populate the finfo struct first
-        my $status = $r->finfo->stat($file, APR::FINFO_NORM, $r->pool);
-
-        ok t_cmp(APR::SUCCESS,
-                 $status,
-                 "stat $file");
+    ok $finfo->isa('APR::Finfo');

+    # stat tests (same as perl's stat)
+    {
         # now, get information from perl's stat()
         our ($device, $inode, $protection, $nlink, $user, $group,
              undef, $size, $atime, $mtime, $ctime) = stat $file;
@@ -81,8 +78,8 @@
                 }
                 else {
                     ok t_cmp(${$method},
-                             $r->finfo->$method(),
-                             "\$r->finfo->$method()");
+                             $finfo->$method(),
+                             "\$finfo->$method()");
                 }
             }
         }
@@ -90,20 +87,20 @@
         # match world bits

         ok t_cmp($protection & S_IROTH,
-                 $r->finfo->protection & APR::WREAD,
-                 '$r->finfo->protection() & APR::WREAD');
+                 $finfo->protection & APR::WREAD,
+                 '$finfo->protection() & APR::WREAD');

         ok t_cmp($protection & S_IWOTH,
-                 $r->finfo->protection & APR::WWRITE,
-                 '$r->finfo->protection() & APR::WWRITE');
+                 $finfo->protection & APR::WWRITE,
+                 '$finfo->protection() & APR::WWRITE');

         if (WIN32) {
             skip "different file semantics", 0;
         }
         else {
             ok t_cmp($protection & S_IXOTH,
-                     $r->finfo->protection & APR::WEXECUTE,
-                     '$r->finfo->protection() & APR::WEXECUTE');
+                     $finfo->protection & APR::WEXECUTE,
+                     '$finfo->protection() & APR::WEXECUTE');
         }
     }

@@ -115,13 +112,13 @@
         }
         else {
             ok t_cmp($file,
-                     $r->finfo->fname,
-                     '$r->finfo->fname()');
+                     $finfo->fname,
+                     '$finfo->fname()');
         }

         ok t_cmp(APR::REG,
-                 $r->finfo->filetype,
-                 '$r->finfo->filetype()');
+                 $finfo->filetype,
+                 '$finfo->filetype()');
     }

     Apache::OK;



--
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to