Date: Wed, 25 Aug 1999 14:02:52 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Laurynas Biveinis cc: DJGPP Workers Subject: Re: symlink() & is_v2_prog() question In-Reply-To: <37C2FC1C.51F4D166@softhome.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 24 Aug 1999, Laurynas Biveinis wrote: > I got a little bit confused by current symlink() code. The reason - > symlink() uses helper function is_v2_prog(), which returns 1 for > v2 DJGPP program, 0 for any other program and -1 for anything else. > The main symlink() code calls this function to determine the type > of linked file. And my question is - why symlink() code checks > only for return value 0, and does not handle -1 ? -1 means that the file doesn't exist. It is perfectly valid to create a symlink to a non-existing file, that's why `symlink' doesn't fail for -1. I believe the comment therein explains this: /* When we are here, either the file exists and is a v2 executable or it does not exist and we hope, the the user knows what he does. */ Apart of the fact that the user might be "she" rather than "he", I don't see any bug here ;-). > Are there > any reasons for keeping current code, which e.g. executes silently > symlink("c:/io.sys", "c:/test.exe") and produces not working > test.exe file? This test.exe will work once the source of the link is created. This is how symlinks work on Unix: you can say "ln -s foo bar" and have `bar' created even thow `foo' does not exist. The link `bar' is useless in this case as long as `foo' doesn't exist. Our `symlink' simply emulates this behavior as best as it can.