summaryrefslogtreecommitdiff
path: root/sdn.cpp
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-10-24 13:07:14 +0200
committerPřemysl Janouch <p@janouch.name>2018-10-24 13:07:14 +0200
commit6aa1e5d8a566578fee2ba4a54ad4d9a7d564f114 (patch)
treea8b8111fb51b5a3258268e6e10a438802a10e6fb /sdn.cpp
parent6e879c9db9612a777bcd0ee009f3dca059124b72 (diff)
downloadsdn-6aa1e5d8a566578fee2ba4a54ad4d9a7d564f114.tar.gz
sdn-6aa1e5d8a566578fee2ba4a54ad4d9a7d564f114.tar.xz
sdn-6aa1e5d8a566578fee2ba4a54ad4d9a7d564f114.zip
Show symlink targets
Rudimentary, needs a refactor.
Diffstat (limited to 'sdn.cpp')
-rw-r--r--sdn.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/sdn.cpp b/sdn.cpp
index 9a1f5c8..10c6361 100644
--- a/sdn.cpp
+++ b/sdn.cpp
@@ -490,7 +490,23 @@ fun reload () {
// http://lkml.iu.edu/hypermail//linux/kernel/0804.3/1616.html
struct stat sb = {};
lstat (f->d_name, &sb);
- g.entries.push_back ({ f->d_name, sb, make_row (f->d_name, sb) });
+
+ auto row = make_row (f->d_name, sb);
+ if (S_ISLNK (sb.st_mode)) {
+ char buf[PATH_MAX] = {};
+ auto len = readlink (f->d_name, buf, sizeof buf);
+ if (len < 0 || size_t (len) >= sizeof buf) {
+ buf[0] = '?';
+ buf[1] = 0;
+ }
+
+ struct stat sbt = {};
+ lstat (buf, &sbt);
+
+ row.cols[row::FILENAME].append (apply_attrs (to_wide (" -> "), 0))
+ .append (apply_attrs (to_wide (buf), ls_format (buf, sbt)));
+ }
+ g.entries.push_back ({ f->d_name, sb, row });
}
closedir (dir);
sort (begin (g.entries), end (g.entries));