I am writing a ls-like program in unix. I got some problem when dealing with relative path.
My program runs correctly in I give absolute path or do not give path (I use "." instead"). However, when provided with relative path, either in ../ format or in ~/ format, I got problems.
MYCODE -l ../../foo
reports an error but ls -l ../../foo can go thought
MYCODE ~/ list all files in the ROOT directory instead of my home directory
I think it is sth due to chdir. Any help?
Pls provide an example. Many thanks.
Pls tell me in which step shall I use chdir (chdir(argv or chdir(entry->d_name), where entry is pointer to struct dirent )
My code can display correct file attributions (drwx..., inode, etc) if provided with absolute paths. But with relative paths, only file name displays correctly.