By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

sequantial processing of files of several directories

P: n/a
Hello, i will simply state algorithm of the problem :

root "r" = GetRootDirectory( );
foreach child directory "c" of "r"
foreach file "f" of "c"
process f ;
endfor
endfor

"process" is not important here, the main problem is how i can reach a
directory, how i can visit all of its childs and catch the files of
all childs sequentially.

Regards

Aug 4 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
kkirtac wrote:
Hello, i will simply state algorithm of the problem :

root "r" = GetRootDirectory( );
foreach child directory "c" of "r"
foreach file "f" of "c"
process f ;
endfor
endfor

"process" is not important here, the main problem is how i can reach a
directory, how i can visit all of its childs and catch the files of
all childs sequentially.

Regards
off-topic I think

I can't see anything related to C++

anyway, there's a hint
File system operation is platform specified
On Windows, check out _FindFirstFile_ on MSDN, or _File_ in Java API
Aug 4 '07 #2

P: n/a
"kkirtac" <ka**********@gmail.comwrote in message
news:11*********************@d55g2000hsg.googlegro ups.com...
Hello, i will simply state algorithm of the problem :

root "r" = GetRootDirectory( );
foreach child directory "c" of "r"
foreach file "f" of "c"
process f ;
endfor
endfor

"process" is not important here, the main problem is how i can reach a
directory, how i can visit all of its childs and catch the files of
all childs sequentially.
Since you gave psuedo code and haven't said what OS, etc.. I'll treat this
as an algorithm problem. Not totally OT but...

Normally I would use recursion for this.

root "r" = GetRootDirectory( );
ProcessDirectory( root );
// done

ProcessDirectory( path )
for each entry in path
if entry is file
process file
else if entry is path
ProcessDirectory( path )
endfor
Aug 4 '07 #3

P: n/a
On Aug 4, 12:52 pm, "Jim Langston" <tazmas...@rocketmail.comwrote:
"kkirtac" <kadir.kir...@gmail.comwrote in message

news:11*********************@d55g2000hsg.googlegro ups.com...
Hello, i will simply state algorithm of the problem :
root "r" = GetRootDirectory( );
foreach child directory "c" of "r"
foreach file "f" of "c"
process f ;
endfor
endfor
"process" is not important here, the main problem is how i can reach a
directory, how i can visit all of its childs and catch the files of
all childs sequentially.

Since you gave psuedo code and haven't said what OS, etc.. I'll treat this
as an algorithm problem. Not totally OT but...

Normally I would use recursion for this.

root "r" = GetRootDirectory( );
ProcessDirectory( root );
// done

ProcessDirectory( path )
for each entry in path
if entry is file
process file
else if entry is path
ProcessDirectory( path )
endfor
Hello, i m sorry i am on a VC++ - Win32 Console project in Visual
Studio 2005..yes i think i need recursion..i m a bit
complicated..which class to use and how..anyway, wrong place to ask
maybe, thanks

Aug 4 '07 #4

P: n/a
On 2007-08-04 12:16, kkirtac wrote:
On Aug 4, 12:52 pm, "Jim Langston" <tazmas...@rocketmail.comwrote:
>"kkirtac" <kadir.kir...@gmail.comwrote in message

news:11*********************@d55g2000hsg.googlegr oups.com...
Hello, i will simply state algorithm of the problem :
root "r" = GetRootDirectory( );
foreach child directory "c" of "r"
foreach file "f" of "c"
process f ;
endfor
endfor
"process" is not important here, the main problem is how i can reach a
directory, how i can visit all of its childs and catch the files of
all childs sequentially.

Since you gave psuedo code and haven't said what OS, etc.. I'll treat this
as an algorithm problem. Not totally OT but...

Normally I would use recursion for this.

root "r" = GetRootDirectory( );
ProcessDirectory( root );
// done

ProcessDirectory( path )
for each entry in path
if entry is file
process file
else if entry is path
ProcessDirectory( path )
endfor

Hello, i m sorry i am on a VC++ - Win32 Console project in Visual
Studio 2005..yes i think i need recursion..i m a bit
complicated..which class to use and how..anyway, wrong place to ask
maybe, thanks
Take a look at the faq, section 5.9 for some suggestions on where better
to ask this question: http://www.parashift.com/c++-faq-lite/
Also, msdn.microsoft.com is a good source and Barry suggested
FindFirstFile() which might be useful.

--
Erik Wikström
Aug 4 '07 #5

P: n/a

Alf P. Steinbach <al***@start.nowrote in message...
* kkirtac:
Hello, i will simply state algorithm of the problem :

root "r" = GetRootDirectory( );
foreach child directory "c" of "r"
foreach file "f" of "c"
process f ;
endfor
endfor

"process" is not important here, the main problem is how i can reach a
directory, how i can visit all of its childs and catch the files of
all childs sequentially.

Check out the Boost library's file and directory support.
FWIW: wxWidgets has a nice set of classes for file/directory.
Most people think of wxWidgets as a GUI, but, it has a flag to turn off the
GUI build.

--
Bob R
POVrookie
Aug 4 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.