About tied filehandles limitation: stat operation

Discussion in 'Perl Misc' started by Alian, Mar 8, 2005.

  1. Alian

    Alian Guest

    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,
    --
    Alain BARBET
     
    Alian, Mar 8, 2005
    #1
    1. Advertising

  2. 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=71423350343770280161397026330337371139054411854220053437565440;
    $m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
     
    Tassilo v. Parseval, Mar 10, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton
    Replies:
    3
    Views:
    9,746
    Pete Becker
    Jun 2, 2005
  2. Patrick Useldinger

    os.stat('<filename>')[stat.ST_INO] on Windows

    Patrick Useldinger, Feb 27, 2005, in forum: Python
    Replies:
    6
    Views:
    1,212
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Mar 3, 2005
  3. Magesh
    Replies:
    3
    Views:
    462
    Gordon Burditt
    Oct 5, 2007
  4. Rolf Krüger
    Replies:
    2
    Views:
    636
    Ian Collins
    Mar 12, 2008
  5. ruck
    Replies:
    10
    Views:
    1,293
Loading...

Share This Page