globbing question 
Author Message
 globbing question

Hi All:

Is there an easy way in C to perform globbing, that is, given a
directory, finding filenames with wildcard patterns, say all filenames
in the form *.jpg? VC++ has CFileFind calls but I don't want to use MFC.

Thanks a lot,

Cuneyt



Tue, 23 Nov 2004 00:22:12 GMT  
 globbing question
On Thu, 06 Jun 2002 11:22:12 -0500, Cuneyt Taskiran said:

Quote:
> Hi All:

> Is there an easy way in C to perform globbing, that is, given a
> directory, finding filenames with wildcard patterns, say all filenames
> in the form *.jpg? VC++ has CFileFind calls but I don't want to use MFC.

Hi,

This is a platform specific question. As such it's off-topic for
comp.lang.c. On, say, POSIX.2 compliant unix systems and linux, you
could use glob(3).

Dave.

--
           David Neary,
     E-Mail: bolsh at gimp dot org
CV: http://www.redbrick.dcu.ie/~bolsh/CV/CV.html



Tue, 23 Nov 2004 00:36:12 GMT  
 globbing question

Quote:

> Is there an easy way in C to perform globbing, that is, given a
> directory, finding filenames with wildcard patterns, say all filenames
> in the form *.jpg? VC++ has CFileFind calls but I don't want to use
> MFC.

No.


Tue, 23 Nov 2004 01:13:01 GMT  
 globbing question


Wed, 18 Jun 1902 08:00:00 GMT  
 globbing question
Hi,

Well, that was exactly my question. Is there a platform independent way
to do it? I was wondering if there was a library to do this.

Thanks,

Cuneyt

Quote:

> On Thu, 06 Jun 2002 11:22:12 -0500, Cuneyt Taskiran said:

>>Hi All:

>>Is there an easy way in C to perform globbing, that is, given a
>>directory, finding filenames with wildcard patterns, say all filenames
>>in the form *.jpg? VC++ has CFileFind calls but I don't want to use MFC.

> Hi,

> This is a platform specific question. As such it's off-topic for
> comp.lang.c. On, say, POSIX.2 compliant unix systems and linux, you
> could use glob(3).

> Dave.



Tue, 23 Nov 2004 01:21:00 GMT  
 globbing question


Wed, 18 Jun 1902 08:00:00 GMT  
 globbing question

Quote:

> Hi All:

> Is there an easy way in C to perform globbing, that is, given a
> directory, finding filenames with wildcard patterns, say all filenames
> in the form *.jpg? VC++ has CFileFind calls but I don't want to use MFC.

Given a directory listing (e.g., a file containing file names, one per
line), you can do this easily enough. Search google/comp.lang.c for
wildcard matching. Several implementations were discussed earlier this
year.

        david

--
If 91 were prime, it would be a counterexample to your conjecture.
    -- Bruce Wheeler



Tue, 23 Nov 2004 02:47:18 GMT  
 globbing question


Wed, 18 Jun 1902 08:00:00 GMT  
 globbing question
Hi,

Under UNIX, I came up with the following program which does the job:

#include <stdio.h>
#include <stdlib.h>
#include <glob.h>

int main()
{
        char pattern[10] = "*.jpg";
        glob_t myglob;
        int numMatch, i;

        glob(pattern, GLOB_DOOFFS, NULL, &myglob);
        numMatch = myglob.gl_pathc;
        for( i=0; i<numMatch; i++ ) {
                printf("%s\n", myglob.gl_pathv[i]);
        }

Quote:
}

Thanks for all the replies,

Cuneyt

Quote:

> Hi All:

> Is there an easy way in C to perform globbing, that is, given a
> directory, finding filenames with wildcard patterns, say all filenames
> in the form *.jpg? VC++ has CFileFind calls but I don't want to use MFC.

> Thanks a lot,

> Cuneyt



Tue, 23 Nov 2004 03:37:54 GMT  
 globbing question


Wed, 18 Jun 1902 08:00:00 GMT  
 globbing question
On Thu, 06 Jun 2002 12:21:00 -0500, Cuneyt Taskiran

Quote:

>Hi,

>Well, that was exactly my question. Is there a platform independent way
>to do it? I was wondering if there was a library to do this.

1) don't top-post
2) don't start new threads to continue the same discussion
3) Dave was right, this is not possible in any platform independent
way, unless the platforms are posix compliant. Otherwise you'd have to
write something specific for each one.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>



Tue, 23 Nov 2004 05:58:46 GMT  
 globbing question


Wed, 18 Jun 1902 08:00:00 GMT  
 globbing question

Quote:

> Hi All:

> Is there an easy way in C to perform globbing, that is, given a
> directory, finding filenames with wildcard patterns, say all filenames
> in the form *.jpg? VC++ has CFileFind calls but I don't want to use MFC.

C doesn't support the above glogging. POSIX supports it.

C interpreter (Ch) has some limited support for cross platform
globbing. There is one example running in Windows/Unix at

http://www.softintegration.com/demos/chstandard/posix.html

Quote:

> Thanks a lot,

> Cuneyt



Sat, 11 Dec 2004 08:23:17 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Globbing

2. File Globbing

3. question question question

4. This is a biztalk question but probably an easy question for you C# guru's

5. Non-Programming Question... experience question mostly

6. Not C program question, historical question

7. A question regarding FAQs question 12.2

8. Question FAQ question

9. Peer to peer board game - possible remoting question or design question

10. if(question) || if question

11. array question - beginner question

12. questions, questions, and than some

 

 
Powered by phpBB® Forum Software