Solved

"Recursive" C wildcards under NT

Posted on 2004-08-01
6
469 Views
Last Modified: 2010-04-15
Hello Experts.

I have a program for win XP, whos syntax is something like

lcfs [options] <indir> <files..>

Where the "files" things are multiple wildcard strings.
Now most Unix Shells would replace "*.bmp" in the files section with all files matching this, but NT doesnt seemt to do so.

But IF it would, what I read will work is you link a certain file or something, I'd have problems with my recursive option(which would, of course, search subdirectorys, too), and the shell wouldnt do that, right?

I thought I'd do something like

main(..) {
listfunction(argv[<indir>])
}

listfunction {
 _findfirst(*)
 while ..{
 if(file is a direcory) listfunction(directoryname)
 else if(filename matches wildcard from <files>) ..
 _findnext..
 }
..
}

But I dont know how to do check if a string matches a wildcard, any suggestions or a better way to accomplish this?

Thanks in advance,

Lord.
0
Comment
Question by:LordTTSeven
  • 3
  • 2
6 Comments
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 25 total points
ID: 11688172
In windows environment you can use FindFirstFile(), FindNextFile() functions
Take a look at:
http://www.codeguru.com/Cpp/W-P/files/comments.php/c4479?thread=52622
http://www.codeproject.com/cpp/recursedir.asp
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 100 total points
ID: 11689031
See e.g. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/listing_the_files_in_a_directory.asp ("Listing the Files in a Directory") which uses the aforementioned functions in C code.
0
 

Author Comment

by:LordTTSeven
ID: 11692353
It seems you got me wrong.

>http://www.codeguru.com/Cpp/W-P/files/comments.php/c4479?thread=52622
doesnt really help.

>http://www.codeproject.com/cpp/recursedir.asp
is c++

>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/listing_the_files_in_a_directory.asp
is not recursive?

It would be easiest if you could give me something that can check if a string matches a wildcard, I think.

Lord.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 11693970
>>is not recursive?

No, but it shows which way to go. To make it recursive, you'd use

void MyFindFunc ( char* pszPath, char* pszWildcard) {

//...

if ( FILE_ATTRIBUTE_DIRECTORY & GetFileAttributes(FindFileData.cFileName))
    MyFindFunc(pszPath, pszWildcard);

}
0
 

Author Comment

by:LordTTSeven
ID: 11694442
I am aware of the way how to make it recursive.

The problem is, that want to search _ALL_ directorys for _SPECIAL_ files(some wildcard).

But if I got you correctly, findfirst/netxfile with wildcard such as "*.extention" will find _ANY_ directorys, too? Or will I have to do a "*" search, check if I have a directory, and do a second search for files with my *.extention wildcard(and another one for the subsub directorys) for each directory I find(Why didnt this idea fly to me earlier)?

If thats the case, everything I did was in vain. Oh well.

Thanks,

Lord.
0
 

Author Comment

by:LordTTSeven
ID: 11694535
[What I forgott in the above Post, sorry for double]

Why I posted this, so you might understand me :)
I thought it would be easiest just run one search with the wildcard "*", call the function recursive if it was a directory other then . and .. ,
and if it was a file manually do a wildcard match on the finddata_thing.name with my wildcard(s) given by the user.

Cheers,

Lord.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now