LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 07-04-2007, 10:42 PM   #1
zacodi
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Rep: Reputation: 0
Need help in displaying the relative path


Hi. I was wondering if somebody can help me on this. I am writing a c program that finds a file and display its relative path if the file is found... I am not sure how I going to display the relative path.. Any suggestions? Thx

int
main (int argc, char * argv[])
{

int fileDesc; /* File Descriptor */
struct stat buf; /* Stat Struct */

if ((fileDesc = open(argv[1], O_RDONLY)) < 0)
{
printf ("%s: %s -- File does not exist.\n",argv[0], argv[1]);
return(1);
}

fstat (fileDesc, & buf);

printf ("filename : %s \n", argv[1]);
printf ("relative path : \n");
printf ("Protection Mode : %o ", buf.st_mode);
printf ("Tot size : %ld\n", buf.st_size);

close (fileDesc);
return (0);

}
 
Old 07-05-2007, 03:57 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
This is a duplicate of:

http://www.linuxquestions.org/questi....php?p=2811522
 
Old 07-05-2007, 04:14 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

http://www.linuxquestions.org/questi...d.php?t=566798


In this case I've closed the original because the dupe was in the more suitable
forum and already had a relevant answer. Please re-visit the rules you agreed to.



Cheers,
Tink
 
  


Closed Thread



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
Question in displaying the relative path oliviapesayco Programming 1 06-30-2007 03:27 PM
[bash] relative path grezly Programming 1 01-16-2007 02:30 PM
relative to absolute path vishalbutte Programming 4 01-14-2006 03:17 PM
Relative Path? mikeshn Linux - General 3 05-10-2002 04:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:38 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