About tied filehandles limitation: stat operation

A

Alian

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 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 ?

Thanks,
 
T

Tassilo v. Parseval

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
 

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top