f



File::Copy::copy With File Handles

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?
0
hsomob1999 (28)
10/18/2011 8:08:47 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

3 Replies
802 Views

Similar Articles

[PageSpeed] 59

Quoth MaggotChild <hsomob1999@yahoo.com>:
> 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?

Both, or indeed any other way of creating a filehandle.

> In either case what's the issue with handles that may lead to data
> loss?

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. If you pass it handles it can't do
that, so it only preserves the Unixy permission bits you get from stat.

Ben

0
ben6057 (1116)
10/18/2011 9:39:54 PM
On Oct 18, 2:39=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth MaggotChild <hsomob1...@yahoo.com>:
>
> > The documentation for File::Copy warns against using file handles as
> > arguments:
>
> > =A0 =A0 =A0 =A0Note that passing in files as handles instead of names m=
ay 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.


0
hsomob1999 (28)
10/19/2011 5:19:57 PM
On 2011-10-19, MaggotChild <hsomob1999@yahoo.com> 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
0
nospam-abuse (478)
10/22/2011 12:15:32 AM
Reply:

Similar Artilces:

copy txt file - only copies 1/3 of the file
File.open('oldFile.txt', 'r') do |f1| #file contains XML type data m = f1.gets File.open('newFile.txt','w') do |f2| #newFile to separate data in oldFile f2.puts m.split("<") end end Hello All. There is something that I did that was weird here. I say this because when I open the new file that it creates its 1/3 the size of the original. It seems to just completely cut off. I took off the .split and it still did this, so I know it has nothing to do with split. What do you think is going on? oldFile.txt contains XML formatted data. ...

File IO/Copy A File
I am stumped on this one... Any easy way to copy a file from a button event in RB 5.2? I basically want the button to copy DB.rdb to DB.bak. THis way is someone hozes the file, we have a backup. Thanks in advance, SJ > I am stumped on this one... > > Any easy way to copy a file from a button event in RB 5.2? I > basically want the button to copy DB.rdb to DB.bak. THis way is > someone hozes the file, we have a backup. > > Thanks in advance, > > SJ Maybe I am missing what you are trying to do - but wouldn't FolderItem.CopyFileTo d...

Copying a file to another file
Hi, I wrote the following C program to copy a file to another file. #include <stdio.h> #include <stdlib.h> static FILE *open_file ( char *file, char *mode ) { FILE *fp = fopen ( file, mode ); if ( fp == NULL ) { perror ( "Unable to open file" ); exit ( EXIT_FAILURE ); } return fp; } int main ( int argc, char *argv[] ) { /* int ch;*/ FILE *from; FILE *to; char *buffer; long lSize; if ( argc != 3 ) { fprintf ( stderr, "Usage: %s <readfile1> <writefile2>\n", argv[0] ); exit (1);/* E...

Copy, copy, copy...
http://www.slate.com/blogs/future_tense/2015/06/08/apple_wwdc_2015_music_news_and_other_things_apple_thinks_it_invented.html On Friday, June 12, 2015 at 9:49:16 AM UTC-4, Nashton wrote: > http://www.slate.com/blogs/future_tense/2015/06/08/apple_wwdc_2015_music_news_and_other_things_apple_thinks_it_invented.html And that was all they ever did, from the very beginning, when they stole from Xerox. On 2015-06-12 18:37:31 +0000, Walter Myer said: > On Friday, June 12, 2015 at 9:49:16 AM UTC-4, Nashton wrote: >> http://www.slate.com/blogs/future_tense/2015/06/08/apple_wwdc_2015_music_news_and_other_things_apple_thinks_it_invented.html >> > > And that was all they ever did, from the very beginning, when they > stole from Xerox. Ummm... No. From that very source: "After so much innovation, it’s no wonder Apple felt the need to take a little time to step back" On 2015-06-12 3:37 PM, Walter Myer wrote: > On Friday, June 12, 2015 at 9:49:16 AM UTC-4, Nashton wrote: >> http://www.slate.com/blogs/future_tense/2015/06/08/apple_wwdc_2015_music_news_and_other_things_apple_thinks_it_invented.html > > And that was all they ever did, from the very beginning, when they stole from Xerox. > I can imagine it's even getting tiresome for their fans. ...

File, Find References, Copy Files: Truncating Long File Names
Hello All- I just experienced this behavior this morning. It was repeatable. Has anyone else seen this? The file Name was cut off after 57 characters. XP Pro SP2 2006 SP0 Office XP 2003 Pro Best Regards, Devon T. Sowell www.3-ddesignsolutions.com How long was the path name in total? Total including the file extension (.SLDASM) = 174. The file Extension was retained, just the Name was chopped off. These are my customer's files. Best Regards, Devon T. Sowell www.3-ddesignsolutions.com "TOP" <kellnerp@cbd.net> wrote in message news:1128364278.638472.150320@f14g2000...

copy all files except dot files
Will the following sequence cd /dest-dir cp /source-dir/* . copy EVERYTHING ? But i don't want those dot files like .profile .sh_history to be copied across. What command to use instead? On 7 Mar 2004 06:28:06 GMT, pui ming Wong <s11976@net2.hkbu.edu.hk> wrote: > Will the following sequence > cd /dest-dir > cp /source-dir/* . > > copy EVERYTHING ? > > But i don't want those dot files like .profile .sh_history > to be copied across. > What command to use instead? > cp /source-dir/* . will not copy dot files. -- Incrsease your earoning pos...

Copying Files and retaining File Permission
Hi, I need to transfer files from ServerA to ServerB. ServerA is the domain controller, and ServerB is the Additional domain controller in the same domain. What is the easiest way to do this? There are folders with ACL granted to domain users. Server A - Windows 2000 Server Server B - Windows 2003 Server Domain - linx.local If I use traditional way to transfer files, it will lose all the permission, and stop halfway if the file is in use. Any software to skip file in use during copy and report the files in log files? I have heard of RoboCopy. Is it useful in this situation, and any guides ...

Copying File or Changing File Date
Hi, How do you change the file creation date of a file in windows using java. I tried the File.setLastModified() method and it is not doing what I hoped it would do which is to change the date time stamp displayed in windows explorer. I basically want to copy a file read via InputStream from a URL and written into a local file system using DataOutputStream. The problem is the file written using DataOutputStream is created ad hoc and creates a "new" file with the current datetime stamp. Is it possible to "copy" a file from a URL source or a server-side file system source ...

Re: copy files with x copy
I'm not aware of a "now" function. Did you want something like this? data _null_; call symput('date',put(today(),yymmdd6.)); run; x copy Test.txt test&date; hth Paul Choate DDS Data Extraction (916) 654-2160 -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of William Kossack Sent: Friday, July 23, 2004 12:13 PM To: SAS-L@LISTSERV.UGA.EDU Subject: copy files with x copy I'm trying to both copy a file and change its name using a macro variable %let date = now(); x copy c:/oldlocation/name d:/newlocation/name&date; what I get is a file with the name and &date "name&date" in the new location what am I doing wrong? ...

Copying Files and retaining File Permission
Hi, I need to transfer files from ServerA to ServerB. ServerA is the domain controller, and ServerB is the Additional domain controller in the same domain. What is the easiest way to do this? There are folders with ACL granted to domain users. Server A - Windows 2000 Server Server B - Windows 2003 Server Domain - linx.local If I use traditional way to transfer files, it will lose all the permission, and stop halfway if the file is in use. Any software to skip file in use during copy and report the files in log files? I have heard of RoboCopy. Is it useful in this situation, and any guides ...

How Do I Copy Over An Existing File in an Obey File?
How embarassing is this. I have two files a and a/zip. When I'm happy with a/zip I'd like to rename it "a" (and do a few other things too, but we'll just stick to the copy / rename / delete problem for now). In Unix, I'd just type "mv a.zip a" and that would generally be that. But writing an Obey file to do it makes my head hurt. If I write "copy a/zip a DFQ~N~P" it does what I want, but prompts me if I want to move the file. So, I thought I'd try deleting, or wiping the file "a" first - but if the file "a" doesn't exist, the script errors and exits. So how do I end up with "a" being replaced by "a/zip" without being prompted (apart from using the UPP's port of "mv")? James In article <8HeWf.37$Nb2.66@news.oracle.com>, James Sargent <root@127.0.0.1> wrote: > How embarassing is this. > > I have two files a and a/zip. When I'm happy with a/zip I'd like to > rename it "a" (and do a few other things too, but we'll just stick to > the copy / rename / delete problem for now). > > In Unix, I'd just type "mv a.zip a" and that would generally be that. > > But writing an Obey file to do it makes my head hurt. > > If I write "copy a/zip a DFQ~N~P" it does what I want, but prompts me if > I want to move the file. Try "A~CDF~L~N~P~QR~S~T~V". That should do it!...

Copy Files with long file names
Hi, I am using CopyFile (Scripting.FileSystemObject) to copy file from one location to another. The naming convention followed makes the file names (+ the path) lenghty and the total characters can exceed 260 characters. I would appreciate if you can let me know if there is any solution to bypass max limit (Filename + Path) of 260 characters. The copying of file from one location to another happens on the click of a button in MS Access Forms. Thanks in Advance. Regards Bala Access Version : Access 2003 The files (can be any type of files like .xls, .doc, .pdf etc..) i...

http://LongPathTool.com - LONG PATH Tool
http://LongPathTool.com - LONG PATH Tool - Windows tool to copy or delete files and folders with path too long error Windows tool to copy or delete files and folders with path too long or filename too long error. Just browse to the file and press a button to copy or detele it, thats it! The application solves the problem with inability to copy and delete files and folders with long paths in Explorer. They could be created by virus/adware/Mac OS/other software. Normally one can't access such files under Windows and therefore can't copy or delete them either. Clean up files. Alows to copy and delete files that has path longer then 260 characters. Alows to copy and delete files that has trailing spaces or trailing dots in its name. If you have ever received a message from Windows like Cannot delete file: Access is denied There has been a sharing violation. The source or destination file may be in use. The file is in use by another program or user. Make sure the disk is not full or write-protected and that the file is not currently in use. Error Deleting File or Folder Cannot delete file or folder The file name you specified is not valid or too long. Specify a different file name. when you tried to delete, move or rename a file, then this program will be helpful. Path Too Long Utility identifies the processes (running programs) that have locked that file, preventing it from being deleted, moved or renamed. Recent changes: Demonstration o...

http://LongPathTool.com - Copy, Unlock and Delete Path Too Long files http://LongPathTool.com
http://LongPathTool.com - Copy, Unlock and Delete Path Too Long files http://LongPathTool.com - Copy, Unlock and Delete Path Too Long files Do you have error messages?, like : Path too long. Error cannot delete file: cannot read from source file or disk Cannot delete file: Access is denied There has been a sharing violation. Cannot delete file or folder The file name you specified is not valid or too long. Specify a different file name. The source or destination file may be in use. The file is in use by another program or user. Error Deleting File or Folder Make sure the disk i...

Cmd-file copy part of itself to temp file !
Thanks to all who replied before. I am up & running using Editor to extract a file that then gets compiled. Works like a charm and I plan to have a new version of my HP2RTF command file available as soon as I pretty it up a bit. The performance difference is.... well, for a dinky little 79-line input file, the new version is about 3 times faster even 1st time, when it compiles part of itself, and about 10 times faster thereafter. Yes, compiled code is sooooo much faster than interpreted that we can run Editor, the Cobol compiler and the linker, and still read and write 79 recor...

Copying files while changing name and variable in file
I need to copy a file and change the name from 1 to 2, and 3, and so on... while doing this 5000 times I also need to sequentially replace 2 variables within the file also sequentially....is there an easy way to do this? I'm completely new to dos so any help would be a great help. thanks in advance!! "Midnight" <jessica_brooks@csx.com> wrote in message news:1146681973.453560.213800@j33g2000cwa.googlegroups.com... > I need to copy a file and change the name from 1 to 2, and 3, > and so on... while doing this 5000 times I also need to sequentially > replace 2 variables within the file also sequentially.... What do you mean by "replace 2 variables within the file"? That could mean just about anything! You need to be *very explicit* and tell us *exactly* what this file contains and *exactly* how it is formatted and *exactly* which parts of it you want to change. > I'm completely new to dos . . . dos? What dos? Is that some kind of disk operating system? Mike set JOB_PATH=.\faxes set JOB_NAME=fax1.job set JOB_FOLDER=%JOB_PATH%\fax1 type sec1.txt > %JOB_PATH%\%JOB_NAME% echo DIDNumber(*5000*9042452000*) >> %JOB_PATH%\%JOB_NAME% type sec2.txt >> %JOB_PATH%\%JOB_NAME% echo From_FaxNumber(*5000*9042452000*) >> %JOB_PATH%\%JOB_NAME% type sec3.txt >> %JOB_PATH%\%JOB_NAME% mkdir %JOB_FOLDER% copy %JOB_PATH%\SinglePageFaxSeed %JOB_FOLDER% This is what I was given... the didnumber *5000 has to chang...

Batch file operation copies files to desktop
Hi, I would like to write a batch file that can do the following: -Copy two files (an .mdb and a .bat) from a location on the network given as an UNC path (e.g. \\servername\sharename\...\myFile.mdb) and save it to the currently logged on user's desktop, using the generic Windows location for <dekstop> whether it is 98, NT or XP. Anybody know how to do this? Thanks in advance. Regards, Jean jeanjanssens@hotmail.com wrote: > Hi, > > I would like to write a batch file that can do the following: > > -Copy two files (an .mdb and a .bat) from a location on the network > given as an UNC path (e.g. \\servername\sharename\...\myFile.mdb) and > save it to the currently logged on user's desktop, using the generic > Windows location for <dekstop> whether it is 98, NT or XP. > > Anybody know how to do this? Thanks in advance. > > Regards, > Jean > If you run the batchfile from the machine the user is logged in this should not be too hard. You can manually create a file somewhere to do the identification of the OS type and thus the location of the desktop folder, and use like an if and goto system, or try and use some built-in variables to determine the OS type. Wim On 14 Apr 2005 06:05:49 -0700, jeanjanssens@hotmail.com wrote: >Hi, > >I would like to write a batch file that can do the following: > >-Copy two files (an .mdb and a .bat) from a loca...

How to copy a HTML file into plain text file
I have a file named test.html, I used following command and copied as test.txt file from dos command shell. copy c:\test.html c:\test.txt The output file, "test.txt" is generated as text formatted file but all the HTML tags are existed around each line. If I use windows "file->save as" function and select to save as ".txt" format, this file is saved as plain text file without HTML tags. How can I save this file from dos command into text formatted (.txt) without HTML tags around ? >I have a file named test.html, I used following command a...

Copy files and ensure that the modified files are not be overwritten.
Hi all, Currently, I meet a the following problem: Suppose I have some folders with some files in each of them. Now, I copy all of these folders into another location and then make some changes, e.g., edit/remove/rename and so on, for some of the files/folders in the old and new location. After that, I want to merge them as one with all of the differences leave as they are, is this possiable? Regards. -- ..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. Hongyi Zhao <hszhao.cn@gmail.com> writes: > After that, I want to merge them as one with all of the di...

Copy files using filenames from text files
How can I do this???? I have the file "lista.txt", and this file have the next information: one.txt two.txt five.txt six.txt ------------------- This files exist in the same directory that "list.txt", I would like to copy this files to other directory Using Windows the batch file would be like this: for /f "tokens=*" %i in (list.txt) do copy "%i" destdir\ How can I do something like that in UNIX?? Best Regards altariamx2003@gmail.com ha escrito: > How can I do this???? > > I have the file "lista.txt", and th...

A file utility to copy a CERTAIN PART of a file ?
In Win XP, does anybody know of a utility program that will copy only a Designated Part of a file? There are already programs, like the iHex hex editor, that will reduce the size of a file, but it truncates the file from the END of the file. I need a program that truncates a file at some other designated spot. Like, in a 100 Kb file that has internal addresses from 0 to 100,000, I want to delete the bytes from 15,000 to 25,000, creating a 90 Kb file. Actually, the file I need to reduce is 2 Gb, but,... Does such a program exist? Thanks very much, Gurus. On 2 Feb 2006 09:51:17 -0800, Mark246@email.com wrote: >In Win XP, does anybody know of a utility program that will copy only a >Designated Part of a file? > >There are already programs, like the iHex hex editor, that will reduce >the size of a file, but it truncates the file from the END of the file. > > >I need a program that truncates a file at some other designated spot. >Like, in a 100 Kb file that has internal addresses from 0 to 100,000, I >want to delete the bytes from 15,000 to 25,000, creating a 90 Kb file. > > >Actually, the file I need to reduce is 2 Gb, but,... Does such a >program exist? > >Thanks very much, Gurus. http://www.fileviewer.com/Features.html J. Mark246@email.com wrote: > In Win XP, does anybody know of a utility program that will copy only a > Designated Part of a file? > > I need a program that truncates a file at some othe...

Re: copy files with x copy #2
Glad it's resolved, but I'm a bit curious because your original code generates a file named namenow() when I try it. That's as expected. On Fri, 23 Jul 2004 14:02:25 -0600, William Kossack <kossackw@NJC.ORG> wrote: >got it > >%let date = %sysfunc(today()); >x copy c:/oldlocation/name d:/newlocation/name&date; > >or better yet use > >%let date = %sysfunc(today(),date.); > > >William Kossack wrote: > >> I'm trying to both copy a file and change its name using a macro variable >> >> %let date = now(); >> x copy c:/oldlocation/name d:/newlocation/name&date; >> >> what I get is a file with the name and &date "name&date" in the new >> location >> >> what am I doing wrong? ...

cannot Copy File: File System Error (1026)
Hi I get this error message when trying to copy from one DRIVE and another. What causes this and how does on prevent/fix this. Thx --------------------------------------------------------------------------- Johan van Zyl - Somerset West - South Africa JVZ Systems CC johan@jvz.co.za Customised Software using Clarion & MS SQL http://www.jvz.co.za http://www.jvz.co.za/pastel - Pastel Utilities & Data Doctor http://www.jvz.co.za/mssql http://communities.msn.co.za/ClarionMSSQL http://communities.msn.co.za/MCSE2001 Johan When I've had this message it normally meant that there is something wrong with the FAT table. I could not even delete the file. Have you tried copying the file to a folder on the same drive? Terry Davidson johan@jvz.co.za (Johan van Zyl - JVZ Systems CC) wrote in message news:<3f7a0855.446570@news.softvelocity.com>... > Hi > I get this error message when trying to copy from one DRIVE and > another. What causes this and how does on prevent/fix this. > Thx > ...

copying nth line from a file to another file
Hi All, I have a database table which is having a column, line_number. I nee to query the table get the line_number and copy only those lines from source flat file to another file. I have not worked much with UNIX Please let me know if anyone has implemented a similar logic. Thank -- supriy ----------------------------------------------------------------------- supriya's Profile: http://fantasticunix.com/forum/member.php?userid=6 View this thread: http://fantasticunix.com/forum/showthread.php?t=50790 On 2008-07-29, supriya <supriya.3daobz@no-mx.forums.yourdomain.com.au> wrote: > > > > Hi All, > I have a database table which is having a column, line_number. I need > to query the table get the line_number and copy only those lines from a > source flat file to another file. I have not worked much with UNIX. > Please let me know if anyone has implemented a similar logic. > > Thanks > > n=$(database query) sed -n "${n}p" <file1 >>file2 2008-07-29, 06:06(+00), Bill Marcum: > On 2008-07-29, supriya <supriya.3daobz@no-mx.forums.yourdomain.com.au> wrote: [...] >> I have a database table which is having a column, line_number. I need >> to query the table get the line_number and copy only those lines from a >> source flat file to another file. I have not worked much with UNIX. >> Please let me know if anyone has implemented a similar logic. [...] > n=$(database query) > sed -n ...

Web resources about - File::Copy::copy With File Handles - comp.lang.perl.misc

Resources last updated: 3/29/2016 3:51:28 AM