Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > About tied filehandles limitation: stat operation

Reply
Thread Tools

About tied filehandles limitation: stat operation

 
 
Alian
Guest
Posts: n/a
 
      03-08-2005
Hello,

I work on a module that allow access to windows share from unix world with help
of samba API. This module allow things like:


use Filesys::Smbclient;
my $smb = new Filesys::SmbClient;
my $fd = $smb->open("<smb://jupiter/doc/general.css")
or die "Can't open it:$!\n";
while (my $l= $smb->read($fd,50)) {print $l; }
$smb->close(fd);

but too with the help of the magic tie command:

use Filesys::Smbclient;
use File::Copy;

local *FD;
tie(*FD, 'Filesys::SmbClient',">smb://jupiter/toto/tata", 0755);
copy(\*FD, "/tmp/toto");

But this last one complain with:
stat() on closed filehandle FD at /usr/local/perl-5.8.5/lib/5.8.5/File/Copy.pm
line 82, <F> line 1.
(The copy command work well even Ive been getting an error code from copy method.)

In perldoc perltie, I can read in BUG section:
Tied filehandles are still incomplete. sysopen(), truncate(), flock(), fcntl(),
stat() and -X cant currently be trapped.

Is this a "todo" or a "can't" ? Can someone give some reasons about this
restriction and where I must read code to understand this warning ?

Thanks,
--
Alain BARBET
 
Reply With Quote
 
 
 
 
Tassilo v. Parseval
Guest
Posts: n/a
 
      03-10-2005
Also sprach Alian:

> I work on a module that allow access to windows share from unix world with help
> of samba API. This module allow things like:
>
>
> use Filesys::Smbclient;
> my $smb = new Filesys::SmbClient;
> my $fd = $smb->open("<smb://jupiter/doc/general.css")
> or die "Can't open it:$!\n";
> while (my $l= $smb->read($fd,50)) {print $l; }
> $smb->close(fd);
>
> but too with the help of the magic tie command:
>
> use Filesys::Smbclient;
> use File::Copy;
>
> local *FD;
> tie(*FD, 'Filesys::SmbClient',">smb://jupiter/toto/tata", 0755);
> copy(\*FD, "/tmp/toto");
>
> But this last one complain with:
> stat() on closed filehandle FD at /usr/local/perl-5.8.5/lib/5.8.5/File/Copy.pm
> line 82, <F> line 1.
> (The copy command work well even I've been getting an error code from copy method.)
>
> In perldoc perltie, I can read in BUG section:
> Tied filehandles are still incomplete. sysopen(), truncate(), flock(), fcntl(),
> stat() and -X can't currently be trapped.
>
> Is this a "todo" or a "can't" ? Can someone give some reasons about this
> restriction and where I must read code to understand this warning ?


The wording in perltie ("still", "can't currently") suggests that this
limitation isn't written in stone. However, in the past I noticed a
certain reluctance among the perl5-porters to add more trappable
operations to tied data-types. At least those are already mentioned in
the docs so there's a chance it's going to be added at some point
(provided someone has the tuits to do it) especially since additions to
the tied interface aren't that intrusive to the core.

Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854 220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($ m+=<=200);
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.9 How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles? PerlFAQ Server Perl Misc 0 01-12-2011 11:00 PM
Why do I have to prefix stat from <sys/stat.h> with the keyword struct? Rolf Krüger C++ 2 03-12-2008 10:38 PM
Date & Time representation in "struct stat" - <sys/stat.h> Magesh C Programming 3 10-05-2007 12:13 PM
struct stat st; stat(fileName.c_str(), &st); hu? Steven T. Hatton C++ 3 06-02-2005 01:50 PM
os.stat('<filename>')[stat.ST_INO] on Windows Patrick Useldinger Python 6 03-03-2005 09:21 AM



Advertisments