delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/12/31/10:39:03

From: "Tim Van Holder" <tim DOT van DOT holder AT pandora DOT be>
To: <djgpp-workers AT delorie DOT com>
Subject: RE: DOZE and WINDOZE versions
Date: Sun, 31 Dec 2000 16:42:15 +0100
Message-ID: <NEBBIOJNGMKPNOBKHCGHKECNCAAA.tim.van.holder@pandora.be>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
In-reply-to: <200012311446.PAA18462@father.ludd.luth.se>
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id KAA21664
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> I've tried running "mv a b" with success. Doesn't mv use rename()?
No; IIRC, it is basically a cp followed by an rm, code-wise.
Then again, it's been a while since I fiddled with fileutils, so I
may be wrong.

Below is a simple program that lowercases all file and directory
names in the current dir. Does this work on WinME too?
Make sure you try it in a variety of places (network drives, dirs
with LFN files, SUBSTed drives, ...).

== start of simple proglet
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <ctype.h>

int __opendir_flags = __OPENDIR_PRESERVE_CASE;

void
decapitate(const char* name)
{
static char lowername[512];
  /* Don't change a CVS directory */
  if (strcasecmp (name, "CVS") == 0)
    return;
  strcpy (lowername, name);
  strlwr (lowername);
  if (strcmp (name, lowername) != 0) {
    printf ("%s -> %s\n", name, lowername);
    if (rename (name, lowername) != 0) {
      perror (name);
    }
  }
}

int
main(void)
{
DIR* dp = NULL;
struct dirent* ep = NULL;
  dp = opendir ("./");
  if (dp != NULL) {
    while ((ep = readdir (dp)) != NULL)
      decapitate (ep->d_name);
    (void) closedir (dp);
  }
  else puts ("Couldn't open the directory.");
  return 0;
}

- Raw text -


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