delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/21/06:57:04

Date: Sun, 21 Dec 1997 13:56:38 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Kevin Cole <kjcole AT well DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Q: How do I pass long pathnames from the command line?
In-Reply-To: <67ed2e$6vl$1@was.hooked.net>
Message-ID: <Pine.SUN.3.91.971221135617.8399S-100000@is>
MIME-Version: 1.0

On 19 Dec 1997, Kevin Cole wrote:

> It mostly works, as far as I have taken it, but I cannot
> figure out how to pass directory strings like "C:\Program Files\" to it in
> a way that it will understand.  I've tried various combinations of forward
> slashes, backslashes, case changes, quotes, etc. (I'd like to avoid using
> C:\PROGRA~1\, since this is supposed to be general enough to run on
> several different machines, and not all will be searching through the
> exact same tree.)
> 
> Is there a simple answer or can someone point me to the right docs?

The problem is, I don't really understand your question.  Are you
asking how to pass file names with embedded blanks from the command
line?  If so, the answer is: use quotes, exactly as you would with any
other Windows utility:

      C:\WINDOWS> foo "c:\Program Files\foo.bar"

(in DJGPP, you may also use single quotes).

If you are asking about file names embedded as strings into your
program, your problem is most probably the single backslashes.  Either
use forward slashes, like in "c:/Program Files/" or double the
backslashes, like in "c:\\Program Files\\".  (Backslashes are special
in C because they are used to escape-protect other special characters,
so you need 2 of them to put a literal backslash.)

>  *    This was written in response to a need to empty cache files in    *
>  * several subdirectories of unknown name and/or depth.  The files to   *
>  * be deleted all end with the same extention but the root (base) name  *
>  * may vary.  The idea was to construct something similar to the NT     *
>  * FOR command, or the VAX/VMS DCL commands, or Unix's find or recurse  *
>  * stuff.                                                               *
>  *                                                                      *
>  *    Usage:    FORGET start_path "filespec"                            *
>  *                                                                      *
>  *    No parameter is optional.  Wildcards may be used for the filespec *
>  * but all constants must be UPPER CASE and quotes MUST be used around  *
>  * the filespec!                                                        *
>  *                                                                      *
>  *      Example:        FORGET C:\ "*.ABC"                              *

You already have all this in DJGPP with no programming at all!  DJGPP
supports the magic "..." wildcard which is recursively expanded by the
DJGPP startup code to all the subdirectories, just like on VMS.  So
all you need is a program that does whatever you need to every argv[]
element (in your case, it's to delete the file), and then you call it
like so:

	forget c:/.../*.abc

That's it!

And if you have the DJGPP port of GNU Fileutils, you can use the `rm'
program form there:

	rm -f c:/.../*.abc

Note that quoted wild-cards are NOT expanded, so if you need to remove
all files under the "Program Files" directory, you need to say
something like this:

	rm -f c:/"Program Files"/.../*.abc

The idea is to quote the embedded blanks, but not the wild-card.

- Raw text -


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