Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: globbing source for C

Reply
Thread Tools

Re: globbing source for C

 
 
Joel C. Salomon
Guest
Posts: n/a
 
      05-12-2011
On Thursday, May 12, 2011 9:07:44 AM UTC-4, Datesfat Chicks wrote:
> Here are other suggestions and thoughts that come to mind:

<snip>
> c)It is my understanding that the treatment of command-line arguments
> has always been different in Windows (i.e. it predates Windows 7 by
> far). *nix globs for you, Windows does not.


Exactly; the OP was asking for pointers on how to implement (in C, so it's on-topic) functionality like that provided by *nix, on a platform where it is not provided.

Turns out the most useful answers are Windows-specific, but a link to some portable library (or to *sh source code!) would have been appropriate, too.

--Joel
 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      05-12-2011
On 2011-05-12, Joel C. Salomon <(E-Mail Removed)> wrote:
> Exactly; the OP was asking for pointers on how to implement (in
>C, so it's on-topic)


The only on-topic answer is "you can't". The C language lacks the
necessary file manipulation primitives.

(Well, maybe. You could in theory do it by iterating over the entire possible
namespace of files using "fopen" and recording which ones you find?)

> Turns out the most useful answers are Windows-specific, but a
>link to some portable library (or to *sh source code!) would have
>been appropriate, too.


No, it wouldn't, because there is no way to write a portable library for that,
and the *sh source code would be useless as it just waves you back at "and
then you use the operating system's mechanism for traversing a directory".

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
 
 
 
Nobody
Guest
Posts: n/a
 
      05-13-2011
On Thu, 12 May 2011 15:57:53 +0000, Seebs wrote:

>> Exactly; the OP was asking for pointers on how to implement (in
>>C, so it's on-topic)

>
> The only on-topic answer is "you can't".


Not for any sane definition of "on-topic".

> The C language lacks the necessary file manipulation primitives.


The C language lacks a lot of things, but that doesn't mean that you
can't write them yourself or obtain them from elsewhere.

On any platform where the concept of globbing is even meaningful, it's
safe to assume that you can enumerate filenames in some
(implementation-defined) manner.

In fact, globbing doesn't absolutely /have/ to be related to filenames;
the concept can be applied to any set of strings.

 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      05-13-2011
On 2011-05-13, Nobody <(E-Mail Removed)> wrote:
> Not for any sane definition of "on-topic".


Uh.

For the ONLY sane definition: "Stuff about the C programming language".

The language is the thing that all the implementations have in common.

If something is held in common between perl on Linux and C on Linux, but
not between C on Linux and C on Windows, it is a Linux thing, not a C thing.

> The C language lacks a lot of things, but that doesn't mean that you
> can't write them yourself or obtain them from elsewhere.


But it does mean that there is no way you can write such a thing "in C" --
that is to say, one which arbitrary C compilers can do something with.

> On any platform where the concept of globbing is even meaningful, it's
> safe to assume that you can enumerate filenames in some
> (implementation-defined) manner.


Probably!

> In fact, globbing doesn't absolutely /have/ to be related to filenames;
> the concept can be applied to any set of strings.


This would be correct except that "globbing" is specifically the term
for expanding a pattern to the list of files matching that pattern. The
term is in fact specific to file names. Pattern matching is not globbing.

Pattern matching can be done in C. Once you've got pattern matching, it
is trivial to show how you would build globbing from it if you had an
enumeration of file names...

-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / (E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      05-14-2011
Seebs <(E-Mail Removed)> writes:
<snip>
> If something is held in common between perl on Linux and C on Linux, but
> not between C on Linux and C on Windows, it is a Linux thing, not a C thing.

<snip>
> On 2011-05-13, Nobody <(E-Mail Removed)> wrote:
>> In fact, globbing doesn't absolutely /have/ to be related to filenames;
>> the concept can be applied to any set of strings.

>
> This would be correct except that "globbing" is specifically the term
> for expanding a pattern to the list of files matching that pattern. The
> term is in fact specific to file names. Pattern matching is not globbing.
>
> Pattern matching can be done in C. Once you've got pattern matching, it
> is trivial to show how you would build globbing from it if you had an
> enumeration of file names...


You need a little more or your assertion that filename globbing is
off-topic would be false. Filenames can be enumerated in standard C --
the problem is that the enumeration is very inefficient and that it does
not terminate. You need at least a terminating enumeration of file
names and, if possible, and efficient one.

--
Ben.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
globbing source for C Owner C Programming 7 05-16-2011 03:14 AM
Globbing files by their creation date tkpmep@hotmail.com Python 3 01-17-2007 04:31 PM
File Copying With Globbing Daz C++ 3 05-03-2006 11:08 AM
globbing multiple wildcards utabintarbo@gmail.com Python 5 05-07-2005 10:40 PM
Case-insensitive globbing Thomas Philips Python 4 06-03-2004 08:47 PM



Advertisments