首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >符号链接文件的cscope

符号链接文件的cscope
EN

Stack Overflow用户
提问于 2015-04-08 23:16:46
回答 4查看 4.4K关注 0票数 6

我有一个包含多个文件的源目录。其中一些是指向其他文件的符号链接。

我创建了一个cscope.files文件。但是当我执行cscope时。对于符号链接的文件,它会报错:

代码语言:javascript
复制
cscope: cannot find file /home/bla/source/file.cc

我认为这不是很好,但也许正确的方法是更改"find“脚本,改为只编写symlink的目的地?

EN

回答 4

Stack Overflow用户

发布于 2015-04-08 23:49:26

目前我使用的是:

代码语言:javascript
复制
# Write only the files which are NOT symlinks
find `pwd` \( \( -iname "*.c" -o -iname "*.cc" -o -iname "*.h" \) -and \( -not -type l \) \) -print > cscope.files
# Add the target of the symlink for all files matching the right extension, and are symlinks
find `pwd` \( \( -iname "*.c" -o -iname "*.cc" -o -iname "*.h" \) -and -type l \) -printf "%l\n"  >> cscope.files

但这似乎是一个糟糕的解决方案。还在寻找一个更好的

票数 6
EN

Stack Overflow用户

发布于 2016-01-29 16:12:24

我认为您可以使用该命令来查找您搜索的文件夹中的所有真实路径

代码语言:javascript
复制
find -L [your searched folder] -name [your searched pattern] -exec realpath {} \; >> cscope.files

例如,如果我想要将已开发的文件夹和linux内核头文件添加到cscope.files中,我将使用这些命令:

代码语言:javascript
复制
find -L `pwd` -iname "*.c" -o -iname "*.h" > cscope.files
find -L /usr/src/linux-headers-3.19.0-15-generic/ -iname '*.h' -exec realpath {} \; >> cscope.files

我希望答案能对你有所帮助。

票数 3
EN

Stack Overflow用户

发布于 2017-01-13 21:39:34

例如,如果您希望将/作为cscope的路径,并希望cscope搜索扩展名为.c/.h/.x/.s/.S的文件,则可以将find命令指定为:

代码语言:javascript
复制
find / -type f -name "*.[chxsS]" -print -exec readlink -f {} \;> cscope.files

这将包括常规文件,包括符号链接的目标。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29518681

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档