From 41cc9a7f3cb9cd4b1857b0209c59ef66929edf03 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Tue, 23 Oct 2012 14:10:19 -0700 Subject: 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. --- src/item.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/item.cc') 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") -- cgit v1.2.3