Solved

"Recursive" C wildcards under NT

Posted on 2004-08-01
6
477 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

630 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