🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #2236

"file cannot be copied onto itself"

#2236
From: Chuck Anderson
Date: Fri, 14 Sep 1990 21:39
23 lines
1612 bytes
Qvestion:

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.

I have written my own "nice" copy command (in Turbo C) to prevent accidental
overwriting (destruction) of a file. The program works fine. It allows the
option of renaming the dest (if it exists), appending to it, overwriting it,
or canceling the copy operation.

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?

  *************************************************************************
     Chuck Anderson                uucp    :         uunet!isis!nyx!cla 
     Boulder, Co. (303) 494-6278   internet:         cla@nyx.cs.du.edu 
  *************************************************************************
Technical Details
Message-ID: <2091@nyx.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!isis!nyx!cla

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!isis!nyx!cla
From: cla@nyx.UUCP (Chuck Anderson)
Newsgroups: comp.os.msdos.programmer
Subject: "file cannot be copied onto itself"
Message-ID: <2091@nyx.UUCP>
Date: 14 Sep 90 21:39:07 GMT
Reply-To: cla@nyx.UUCP ()
Organization: Public Access Unix - University of Denver
Lines: 23