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);
}
|