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 02-21-2004, 04:31 PM   #1
serotonincy
LQ Newbie
 
Registered: Jan 2004
Location: Michigan
Posts: 4

Rep: Reputation: 0
Lightbulb Directory travesal program


Hi,

Has anyone have any idea how to write a program to traverse thru a directory? I tried but had a false start. I can't even open a directory with "opendir" command to begin with. Is that something to do with permission? But I think I have read, write and execution right for that directory. I'm so totally clueless...

Thanks
 
Old 02-21-2004, 04:40 PM   #2
german
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Debian etch, Gentoo
Posts: 312

Rep: Reputation: 30
What language are you talking about using
 
Old 02-22-2004, 11:34 AM   #3
haobaba1
Member
 
Registered: Jul 2003
Location: VA Tech
Distribution: Mandrake 9.1
Posts: 73

Rep: Reputation: 15
Re: Directory travesal program

Quote:
Originally posted by serotonincy
Hi,

Has anyone have any idea how to write a program to traverse thru a directory? I tried but had a false start. I can't even open a directory with "opendir" command to begin with. Is that something to do with permission? But I think I have read, write and execution right for that directory. I'm so totally clueless...

Thanks
Are you sure it is a directory you are trying to open? opendir returns null if the name is not a directory, but it may be a file. In the case that it may be a file you need to use the "readdir" function on the directory that contains the file, or current directory, this returns a " struct dirent* ". Successive calls to readdir return the next file in the directory, when the end is reached readdir returns NULL. You use the function "stat" to find out information about the file. The functions "getpwuid"and "getgrgid" return the user id and group id of the owner fo the file. And yes read permissions are needed on the directory.

Hope this helps
 
Old 02-22-2004, 12:42 PM   #4
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
just do a system call "system("cd /dir");"
 
  


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
Program directory help... JustinCoyan Slackware 3 04-19-2005 10:27 AM
Which directory should I install a program in? LinuxPadawan Linux - General 6 04-11-2005 05:20 PM
Does Linux have a Program Files directory? aznluvsmc Linux - Newbie 4 08-24-2004 08:26 PM
Program Directory nodnarb Linux - Software 2 07-18-2004 09:18 PM
Linux program directory SciYro Programming 7 05-21-2004 09:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration