File::Copy::copy() dies on identical files?

I'm giving File::Copy's tests a bit of a face-lift and I came across
this:

    eval { copy("copy-$$", "copy-$$") };
    printf "ok %d\n", 15+$loopconst
	unless $@ =~ /are identical/ && -s "copy-$$";

which basically says, "copy() should die if given the same source and
destination file" which is a little extreme.  Warn perhaps, but not
die.  I think it's just parroting the behavior of the 'cp' shell
command.

If nobody has any objections, I'll downgrade that to a warning and
copy() just succeeds.  Perhaps it should touch the file in question to
simulate a copy.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
i need another hit
just gimme some fucking paste
please, it hurts so bad
	-- Fmh
0
schwern
10/14/2001 6:02:10 AM
perl.perl5.porters 48287 articles. 1 followers. Follow

2 Replies
909 Views

Similar Articles

[PageSpeed] 57

On Sun, Oct 14, 2001 at 02:02:10AM -0400, Michael G Schwern wrote:
> I'm giving File::Copy's tests a bit of a face-lift and I came across
> this:
> 
>     eval { copy("copy-$$", "copy-$$") };
>     printf "ok %d\n", 15+$loopconst
> 	unless $@ =~ /are identical/ && -s "copy-$$";
> 
> which basically says, "copy() should die if given the same source and
> destination file" which is a little extreme.  Warn perhaps, but not
> die.  I think it's just parroting the behavior of the 'cp' shell
> command.
> 
> If nobody has any objections, I'll downgrade that to a warning and
> copy() just succeeds.  Perhaps it should touch the file in question to
> simulate a copy.

No objections about the downgrading-- I added the croak
(see change #11526).

While you are at it, please add the same skip if $Config{d_link} and
the dev,ino from stat() match.

I don't know about the timestamping, though.  One could argue that
nothing happened.  Moreover, the File::Copy commands *are* trying to
mimic the shell commands.  cp does no steenking timestamp touching.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
10/16/2001 4:37:14 AM
> (see change #11526).

....and #11555.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen
0
jhi
10/16/2001 4:38:17 AM
Reply:

Similar Artilces:

File.Copy and File.CopyTo DO NOT COPY CONTENTS OF FILE!@
I posted on here before but no one has been of any help. I am trying to copy files of type .zip .jpg and .pdf from ones folder to another (I dont want to move it, just make a copy). How can I do this? When I use File.Copy and File.CopyTo it makes a new file in the right folder but has no content and it also erases the content on the orignal file. WTF? This is really making me mad. Visit VistaForums.com #1 Windows Vista Forum Here you go --->  http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=207Regards, Narayana Rao Surapaneni Architect | Author | MCSD for .NET | MCSD | SCJP ww...

File.Copy does not release the lock on the copied file.
 Hi! I am trying to use the File.Copy function in order to copy a file from the Client's PC to the Server. The File to be copied is selected by the user using the FileUpload control and is then used by the server to perform certain operations. My problem is that when I copy the file using the File.Copy method and then execute a streamreader process on the file straight after, I get the following error; "The process cannot access the file '\\syddev1\latest\xmasEmail.html' because it is being used by another process. " Below is the piece of code where the problem...

Copying more than one file using File::Copy
Good day=3B I apologize in advance if this is a very stupid question=85 I=27m trying to concatenate two files and have the results written to a = third file=2E = Maybe I=27m missing something obvious=2E=2E=2E but in Perldoc for File=3A= =3ACopy I = read=3A =22The copy function takes two parameters=3A a file to copy from = and = a file to copy to=2E=22 What can I do if I have a second file I want to copy from=3F (i=2Ee=2E Li= ke = DOS copy command=3A c=3A=5C file1=2Etxt + file2=2Etxt file3=2Etxt will co= py the = contents of file1=2Etxt =26 file2=2Etxt and put the...

Copying all files in a directory using either file.copy or directory.copy across volumes
I need to copy all the files from a cd directory to a directory on my harddrive. I have tried the directory.copy method but it will not allow me to copy across volumes. I have tried the file.copy method but you must specify a file name in the path as well as the target. This sort of defeats the purpose of what I am trying to do. Basically I am using a radio button to specify a type of CD and based on this selection the application knows what directory to look in for the files I want. Here is the script I tried last to move the file. Sub KPacs(ByVal sender As Object, ByVal e As System.EventA...

Problems with File.Copy() Method for copy big files
I´m using the follow commando to copy a file: source = "c:\\domains\\pagina.com.br\\wwwroot\\folder\\filesou.xml";target = "c:\\domains\\pagina.com.br\\wwwroot\\folder\\filetar.xmb"; File.Copy(source, target, true); If I used a small file (source) with for example 233000 bytes the server copy to target without problems. But if I used the file (source) with 700000 bytes the server don´t copy. I´ m copy to the same folder... Why is this happened with big file as source ? Thank you... Rogério Does it throw any error. HighOnCodingWanna get high! I don´t know if it throw any error.Ho...

Error when copying using File.Copy and files exist
I'm trying to copy and overwrite files to an existing directory using :file.copy(source,destination,true)The command works perfectly when the files do not exist, but when trying to overwrite the files, I get an access denied error to the destination directory and files.It's not a permission issue because the folders have 'ASPNET' and 'Everyone' Access set up with full rights.Anyone have any ideas?Thanks in advance.JeffJeff Wasilauski, MCAD .NET, MCPC# WEB DEVELOPMENT-SQL SERVER DBA"If I have answered your question please mark as answer" Check if the File exists before copying and...

copying a file without using module File::Copy
Hello All, Is the only way to copy a file from one directory to another by using the copy module...? Would anyone have a snipet of code copying a file from one dir to another... Any assistance would be appreciated... Thank you, Mike ------------------------------------------------ On Fri, 14 Feb 2003 10:13:06 -0500, Michael Pastore <Michael.Pastore@frontstep.com> wrote: > > Hello All, > > Is the only way to copy a file from one directory to another by using the > copy module...? > > Would anyone have a snipet of code copying a f...

file to file copy
--nextPart3236501.eDU2PhZZ46 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit hello, i have to write a perl script which copies text from one file to another but only if the text is not exisiting yet. For example: in file1: word: moon word2: sky .... the same syntax for every line in file2: #some text word: honey word3: lol word4: mu .... as well the same syntax for every line so now i want to merge file1 into file2, so that word: honey will be replaced by word: moon and word2: sky will be appended to file2. i have written the following...

Problem Copying a file from remote client using File.Copy
Hello, I have to copy a file that is uploaded from a remote client to Web Server into my application folder. I am using the following logic to achieve this. File.Copy(srcPath, destPath) Where srcPath = Path selected by the user using HTML File Input Control. and destPath = Server.MapPath(Excel_Upload) + "\Sample.xls" This works fine when I try uploading the file from the server system but when I try doing the same from a remote client, I get an exception which says "File.Copy Could not find a part of the path 'C:\Documents and Settings\Anas\Desktop\Sample12.xls'&...

What is the maximum file size that can be copied using File.Copy method ?
What is the maximum file size that can be copied using File.Copy method ?HighOnCodingWanna get high! It should only be restricted by available space. The copy function is just a wrapper for the Win32 copy funtion in kernal32.dll salam azam i do not know if this usefulhttp://forums.asp.net/1015306/ShowPost.aspxFadil Alnassar www.fadilalnassar.com | FREE Nodil Tab Controlhttp://www.mefranchising.com Thanks It was helpful. HighOnCodingWanna get high! great to know this .......i owe you alot brother !! i always feel that i like to help people who always help meFadil Alnassar www.fa...

copy files..move files
--____QXYMBNVZTGQSRWCBRQBC____ Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable I noticed that when a folder is moved from one directory to another it = does not show the owner as the person who moved the folder. If you copy = the file to another location on the same server it shows the person's id = of who copied it. I thought before when someone accidently moved a = folder/file you can see the owner and that would the person who moved = it.=20 The other day someone moved a folder to another folder on the same server = by accident....

Copy error with File::Copy
Hi, I used the File::Copy module to copy() 4 files from a PC server to a Mac external firewire drive. Three of the four files copied great! (Thanks for all your help on that.) The one file that didn't copy was a QuickBooks database file. When the perl script ran, I got the following error: Can't copy file /Volumes/PRINCETON;DELLSERVER-1/DatabaseQB.QBW to /Volumes/10GB Firewire Drive/DatabaseQB.QBW-05-04-04.bak - Resource deadlock avoided A file called DatabaseQB.QBW-05-04-04.bak WAS created, BUT it had 0k in the file. The other three copied fine. Just this one...

eegads! File::Copy not copying
Everything "was" perfect in my little program. I gave it a test run today. My file which copies some demofiles is sending blank empty files. I've used -e to make sure it exists and checked the return value on the copy(). Both check out fine. But the files have no content. Any suggestions? This is a snippet from one copy statement: my$ok = ""; $ok = copy("/$htmlroot/$htmldir/demosite/$filenames[$i]","/$htmlroot/$htmldir/$files[$i]") || push(@messages, "Couldn't copy /$htmlroot/$htmldir/demosite/$filenames[$i],\n to /$h...

Script file to copy files
Dear all, I have an external hard disk with lots of big files and a lot of small matlab script files .m. I would like to grab all the files inside that harddisk that have the .m extension or the *.mat file extension (both are matlab files). Of course this is a -first-find the *.m files script and -then copy the files into the hard disk. What I do not know is how I can also keep the structure of the folders containing the *.m and *.mat files when I will copy them in my local hard disk. As this external hard disk contains 2TB of data it is not possible to copy all the fi...

Web resources about - File::Copy::copy() dies on identical files? - perl.perl5.porters

Resources last updated: 1/18/2016 1:54:19 PM