• 6153阅读
  • 3回复

关于搜寻路径的问题 [复制链接]

上一主题 下一主题
离线chenyo
 
只看楼主 倒序阅读 楼主  发表于: 2008-05-06
— 本帖被 XChinux 执行加亮操作(2008-05-07) —
各位大大们

我自已有用qt4写了一个小程式,这个程式会开启一些档案,但这些档案的路径是写成固定的,
我想要写成可以跨linux版本,但是不知道如何正确的写出来,
请教各位大大如何搜寻路径及取得我想要的路径,例如:

假设在  /usr/share/  底下有个  mydir  的资料夹
也就是:/usr/share/mydir/

而其它linux版本的位置会在不同的位置,例如:
/usr/local/share/  底下
也就是:/usr/local/share/mydir/

请问各位大大
我要如何去取得  mydir  之前的路径呢?
想要让我的程式可以找到  /usr/share/  或  /usr/local/share/  路径之后可以接到  mydir/

谢谢
   
       
离线XChinux

只看该作者 1楼 发表于: 2008-05-07
目录不是自己建的??没规律???如何判断?
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线lzian
只看该作者 2楼 发表于: 2008-05-07
提个建议吧:
写一个shell脚本,查找你的mydir,分析一下结果
离线steinlee

只看该作者 3楼 发表于: 2008-05-16
One way to solve the problem is that your code can try to find mydir in /usr/share/ first. If mydir is not there, your code tries /usr/local/share/. If  /usr/share/ and /usr/local/share/ both have mydir, your code can still detect which is the right one.
Looking for remote C/C++ and Qt 兼职
快速回复
限100 字节
 
上一个 下一个