LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-09-2004, 12:09 AM   #1
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Rep: Reputation: 31
finding files in C++


Hello:

I have a question I hope someone could help me

Is there a way to know which files are there in the directory where a exe is? I mean, I have my.exe and I wrote in c++. I want it to be able to see all the files in that dir and choose only those with extension *.txt let's say...

If there's a way to find out the info about the files, I can manage to choose only those I want........ is there a command or a sentence for that?

I have another newbie question.... that very same program reads files in order to work, and if it doesn't have any parameters in command line, I want it to do as I stated above.... however, if I do pass it a parameter I want it to read the file I pass:

my.exe thisFile.txt b.txt c.txt

And that does work, it reads all the parameters... however, if I pass too many parameters:

my.exe a.txt b.txt c.txt d.txt e.txt f.txt g.txt h.txt

it just reads like the first 5 or something and then hangs.... inside there's just a for loop that keeps reading the files, is there a problem about passing too many parameters? too long the command instruction maybe? any work around?

Thanks for your help and your time.

poeta
 
Old 07-09-2004, 01:39 AM   #2
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
There are a few system calls in windows which will help you browse the
directory structure.. i mean to find the files in the directory. Check out the
online MSDN for those system calls
 
Old 07-11-2004, 01:25 AM   #3
shrey_j
Member
 
Registered: Jul 2004
Location: Delhi
Distribution: FC3, RH 9.0
Posts: 39

Rep: Reputation: 16
hi poeta_boy,

I'll try and answer with whatevr I know!

Firstly, talking about Linux, there is a structutre called stat in linux/stat.h (i presume, i cannot crosscheck right now). This stat stores all the info about a file, and even a directory is a file. there is an element which stores all the included files to which a directory is linked. try that out

Also there is no problem with number of parameter, as every thing is stored in the argv[][] array, and can be addressed simply by an integer. There must be some problem in array traversing from you side.

I hope it works
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding Files Through Urpmi ??? ddrfreak Mandriva 8 12-12-2004 11:00 AM
Finding six month old files arockia Linux - Software 11 09-01-2004 09:37 AM
Finding files brentos Linux - General 3 03-22-2004 08:24 PM
Finding files Nicksan Linux - Software 3 06-30-2003 07:16 PM
Finding files question... tarballed Linux - General 1 03-05-2003 01:01 PM


All times are GMT -5. The time now is 07:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration