summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-10-25 12:52:03 -0700
committerJohn Wiegley <johnw@newartisans.com>2012-10-25 12:52:03 -0700
commit34ca6b3991d63dd04d60286452399c7e0d49974b (patch)
tree09629526f7dd09e9bcaf4a41ed7df8b326c6a1eb /src/item.cc
parentde729114d1be1e6b0bb92c3b5e3f157308c67eae (diff)
parent4b261f99bc56853b3468a8a1bb5b4af39ed67af5 (diff)
downloadfork-ledger-34ca6b3991d63dd04d60286452399c7e0d49974b.tar.gz
fork-ledger-34ca6b3991d63dd04d60286452399c7e0d49974b.tar.bz2
fork-ledger-34ca6b3991d63dd04d60286452399c7e0d49974b.zip
Merge pull request #95 from enderw88/Bug695-init-file
Bug695 init file
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc22
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")