Path: utzoo!attcan!uunet!world!decwrl!mips!prls!philabs!crpmks!billb From: billb@crpmks.UUCP (Bill Bochnik ) Newsgroups: comp.os.msdos.programmer Subject: Re: "file cannot be copied onto itself" Message-ID: <1213@crpmks.UUCP> Date: 17 Sep 90 17:23:57 GMT References: <2091@nyx.UUCP> Reply-To: billb@crpmks.UUCP (Bill Bochnik (Info Systems)) Organization: Ciba-Geigy Corporation Lines: 25 Summary: Expires: Sender: Followup-To: Distribution: Keywords: >How does the DOS "copy" command know when the source and destination file are >one in the same (i.e., "file cannot be copied onto itself")? I can't believe >that it's just a string compare. The logistics of that are pretty awkward. > [ Stuf go bye bye] >Then I hit this stumbling block. How do you know if you are going to try to >write a file onto itself? This sounds simple, but seems rather complex to me >after trying a few things. You cannot *simply* compare the two names. That >involves a lot of analysis as to just how the files were specified on the >command line. There must be a better way. > >How does one determine that two files are indeed the same physical file? > How about opening the source file for reading, then open the destination file for writing. The second operation should return an error if the two files are the same physical one. -Bill