diff options
author | Craig Earls <enderw88@gmail.com> | 2012-10-23 14:10:19 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2012-10-23 14:10:19 -0700 |
commit | 41cc9a7f3cb9cd4b1857b0209c59ef66929edf03 (patch) | |
tree | aa27fa27e47d6184591381dd62a1738148efce90 /src/item.cc | |
parent | 14dcb277778568b9c5b60612e4f696363db4de11 (diff) | |
download | fork-ledger-41cc9a7f3cb9cd4b1857b0209c59ef66929edf03.tar.gz fork-ledger-41cc9a7f3cb9cd4b1857b0209c59ef66929edf03.tar.bz2 fork-ledger-41cc9a7f3cb9cd4b1857b0209c59ef66929edf03.zip |
Added filebase and filepath values
'filename' returns the complete path/filename of the file containg the current xact.
This is inconvenient for some displays. filebase returns only the base name. For
completeness added filepath as well.
Diffstat (limited to 'src/item.cc')
-rw-r--r-- | src/item.cc | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/item.cc b/src/item.cc index 0630043b..24d03ba1 100644 --- a/src/item.cc +++ b/src/item.cc @@ -330,6 +330,21 @@ namespace { return NULL_VALUE; } + value_t get_filebase(item_t& item) { + if (item.pos) + return string_value(item.pos->pathname.filename().string()); + else + return NULL_VALUE; + } + + value_t get_filepath(item_t& item) { + if (item.pos) + return string_value(item.pos->pathname.parent_path().string()); + else + return NULL_VALUE; + } + + value_t get_beg_pos(item_t& item) { return item.pos ? long(item.pos->beg_pos) : 0L; } @@ -456,7 +471,12 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind, case 'f': if (name == "filename") return WRAP_FUNCTOR(get_wrapper<&get_pathname>); - break; + else if (name == "filebase") + return WRAP_FUNCTOR(get_wrapper<&get_filebase>); + else if (name == "filepath") + return WRAP_FUNCTOR(get_wrapper<&get_filepath>); + break; + break; case 'h': if (name == "has_tag") |