File::Copy::copy With File Handles

Discussion in 'Perl Misc' started by MaggotChild, Oct 18, 2011.

  1. MaggotChild

    MaggotChild Guest

    The documentation for File::Copy warns against using file handles as
    arguments:

    Note that passing in files as handles instead of names may lead
    to
    loss of information on some operating systems; it is
    recommended
    that you use file names whenever possible.

    Does this refer to handles created with the older FileHandle module
    (which is used in the module's synopsis), IO::Handle subclasses, or
    both?

    In either case what's the issue with handles that may lead to data
    loss?
    MaggotChild, Oct 18, 2011
    #1
    1. Advertising

  2. MaggotChild

    MaggotChild Guest

    On Oct 18, 2:39 pm, Ben Morrow <> wrote:
    > Quoth MaggotChild <>:
    >
    > > The documentation for File::Copy warns against using file handles as
    > > arguments:

    >
    > >        Note that passing in files as handles instead of names may lead
    > > to loss of information


    > On non-Unix systems (more specifically, on Win32 and I believe VMS)
    > File::Copy calls the system file-copy routine (CopyFile on Win32) if you
    > pass it filenames. This will preserve things like ACLs, extended
    > attributes, NTFS streams, and so on.


    I had ignored the obvious and interpreted "loss of information" to
    mean loss of the file's data, not necessarily metadata. Which lead to
    me to believe that for some subtle reason File::Copy couldn't be used
    reliably copy data streams. Thanks for the clarification.
    MaggotChild, Oct 19, 2011
    #2
    1. Advertising

  3. On 2011-10-19, MaggotChild <> wrote:
    >> On non-Unix systems (more specifically, on Win32 and I believe VMS)
    >> File::Copy calls the system file-copy routine (CopyFile on Win32) if you
    >> pass it filenames. This will preserve things like ACLs, extended
    >> attributes, NTFS streams, and so on.

    >
    > I had ignored the obvious and interpreted "loss of information" to
    > mean loss of the file's data, not necessarily metadata. Which lead to
    > me to believe that for some subtle reason File::Copy couldn't be used
    > reliably copy data streams. Thanks for the clarification.


    The division into data/metadata is a tricky stuff. For example, "the
    metadata" may contain the character encoding of a text file. If lost,
    it would render the "data" completely useless.

    Or the "thumbnail lower-resolution image" of a photo file. On
    filesystems with arbitrary metadata allowed, the natural place for the
    thumbnail image is in the metadata. On legacy filesystems, the viewer
    program would be forced to either recalculate it each time, or put it
    into the EXIF sections of the file (thus changing "THE DATA") or keep
    it somewhere where it does not survive renaming of the file.

    Yours,
    Ilya
    Ilya Zakharevich, Oct 22, 2011
    #3
    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. Mike Kiefer
    Replies:
    1
    Views:
    386
    Mike Kiefer
    Sep 21, 2004
  2. D. Alvarado

    Open file handles

    D. Alvarado, Jul 21, 2003, in forum: Java
    Replies:
    1
    Views:
    637
    Gordon Beaton
    Jul 21, 2003
  3. Denis Remezov
    Replies:
    12
    Views:
    3,846
    Denis Remezov
    May 11, 2004
  4. Thomas Bartkus

    Open file handles?

    Thomas Bartkus, Aug 8, 2006, in forum: Python
    Replies:
    3
    Views:
    418
    danielx
    Aug 10, 2006
  5. eino
    Replies:
    1
    Views:
    432
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=
    May 8, 2007
Loading...

Share This Page