delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/07/04:13:20

Date: Thu, 7 Jan 1999 11:13:37 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Doug Kaufman <dkaufman AT rahul DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: ANNOUNCE: bzip2 port to DJGPP
In-Reply-To: <Pine.SUN.3.96.990106073856.22973A-100000@waltz>
Message-ID: <Pine.SUN.3.91.990107111237.17507C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Wed, 6 Jan 1999, Doug Kaufman wrote:

> I had no idea that filenames with more than one "." were allowed on
> Windows 9x. When I said "long filenames will probably be preserved", I
> really meant to say "more than 8 characters of the filename will
> probably be preserved".

``Long file names'' is about much more than just the length of a file
name.  There are some characters, like `+', that DOS disallows in file
names, but Windows 9X permits; there are multiple dots, including a
leading dot, that are permitted; and there are extended file-oriented
services, like 3 times per file instead of just one.

> I'll try to incorporate these suggestions and redo the
> port. All other suggestions welcome.

I think I know why does the program fail with "Permission denied":
it's because you used _dos_getattr and _dos_setattr to copy attribute
bits.  These functions don't support long file names, so they fail for
a name like foo.bar_c.bz2.

You should use _chmod instead, like this:

   retVal = _chmod ( dstName, 1, _chmod (srcName, 0, 0) & 0xffe6) == -1;

(The AND with 0xffe6 is because you cannot have the volume and
directory bits in the value passed to _chmod, otherwise the call will
fail.)

As a bonus, with the above replacement you don't need the separate
ifdef'ed block that declares a variable and calls _dos_getattr.

Btw, this piece of code should probably be conditioned on __MSDOS__,
not on __DJGPP__, since any other DOS port will want it.  For example,
Borland C also has the _chmod function.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019