如何打印由c中的符号链接指向的文件的路径,例如树或ls -l di
这是我的问题: 我用C语言写一个简化的树命令。 当我找到一个符号链接的文件时,我会打印类似的内容:
smybolicfile-> ../../.././ something ..
所以我尝试使用readlink()函数来执行此操作,但是它并未像LS -L或TROED命令一样打印指向符号链接的文件。
例如: 如果我的符号链接文件有0/1/2/3/符号,并且指向的文件在0/1/a/b/filepointed中。
我的程序打印:符号 - > 0/1/a/b/filepoint 但是我想要这个:象征性 - > ../../../../././a/b/filepointed(如ls -l或树所做的)。
那么,这是什么方法呢?
here's my problem:
Im writing a simplified tree command with C language.
When I find a file that's a symbolic link i would print something like:
SymbolicFile -> ../.././something..
So i've tried to do that using readlink() function, but it does not print the file pointed to the symbolic link as the ls -l or tree command does.
for example:
if my symbolic link file is there 0/1/2/3/symbolic and the file pointed is in 0/1/a/b/filepointed.
My program prints: symbolic -> 0/1/a/b/filepointed
But i want this: symbolic -> ../../.././a/b/filepointed (as ls -l or tree does).
So what would be a way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论