ADD_EXECUTABLE( poolquery poolquery.cc )
TARGET_LINK_LIBRARIES( poolquery zypp )
+
+ADD_EXECUTABLE( pathinfo pathinfo.cc )
+TARGET_LINK_LIBRARIES( pathinfo zypp )
--- /dev/null
+#include <iostream>
+
+#include "zypp/Pathname.h"
+#include "zypp/PathInfo.h"
+
+using std::cout;
+using std::endl;
+using std::string;
+using namespace zypp;
+
+int main (int argc, const char ** argv)
+{
+ Pathname datadir(SRC_DIR "/data/pathinfo");
+ Pathname alink = datadir / "alink";
+ PathInfo alinkinfo(alink);
+
+ cout << "alink exists: " << alinkinfo.isExist() << endl;
+ Pathname alinkExp = filesystem::expandlink(alink);
+ cout << "alink expands to: " << alinkExp << endl;
+ cout << "alinkExp exists: " << PathInfo(alinkExp).isExist() << endl;
+
+ Pathname subdirlink = datadir / "subdirlink";
+ PathInfo subdirlinkinfo(subdirlink);
+
+ cout << "subdirlink exists: " << subdirlinkinfo.isExist() << endl;
+ Pathname subdirlinkExp = filesystem::expandlink(subdirlink);
+ cout << "subdirlink expands to: " << subdirlinkExp << endl;
+ cout << "subdirlinkExp exists: " << PathInfo(subdirlinkExp).isExist() << endl;
+}
for (count = level_limit; info.isLink() && count; count--)
{
- DBG << "following symlink " << path << std::endl;
- path = readlink(path);
+ DBG << "following symlink " << path;
+ path = path.dirname() / readlink(path);
+ DBG << "->" << path << std::endl;
info = PathInfo(path, PathInfo::LSTAT);
}
// check for a broken link
if (PathInfo(path).isExist())
return path;
- // broken link, return and empty path
+ // broken link, return an empty path
else
{
ERR << path << " is broken (expanded from " << path_r << ")" << endl;