aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-24 21:59:46 +0200
committerAdrian Kummerländer2014-04-24 21:59:46 +0200
commitff92d0af44fa454d066f6ee3fe2becd97206b64e (patch)
treeb9998826d95e85bf3f09104234f0ef8fa7bba2de /src/function
parenta31fc1169edb33126242eb035dc038cbdea407e8 (diff)
downloadInputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.tar
InputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.tar.gz
InputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.tar.bz2
InputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.tar.lz
InputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.tar.xz
InputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.tar.zst
InputXSLT-ff92d0af44fa454d066f6ee3fe2becd97206b64e.zip
Expanded FunctionReadDirectory class to return files and directories
* they are marked appropriately by a _type_ attribute
Diffstat (limited to 'src/function')
-rw-r--r--src/function/read_directory.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index 0ed33bc..22653b6 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -34,16 +34,34 @@ xalan::XObjectPtr FunctionReadDirectory::execute(
this->fs_context_.iterate(
arguments[0]->str(),
[&domDocument, &rootNode](const boost::filesystem::path& p) {
- XMLCh* buffer = xercesc::XMLString::transcode("file");
- xercesc::DOMNode* const fileNode = domDocument->createElement(buffer);
+ XMLCh* buffer = xercesc::XMLString::transcode("item");
+ xercesc::DOMElement* const itemNode = domDocument->createElement(buffer);
+ xercesc::XMLString::release(&buffer);
+
+ buffer = xercesc::XMLString::transcode("type");
+
+ if ( boost::filesystem::is_regular_file(p) ) {
+ XMLCh* valueBuffer = xercesc::XMLString::transcode("file");
+
+ itemNode->setAttribute(buffer, valueBuffer);
+
+ xercesc::XMLString::release(&valueBuffer);
+ } else if ( boost::filesystem::is_directory(p) ) {
+ XMLCh* valueBuffer = xercesc::XMLString::transcode("directory");
+
+ itemNode->setAttribute(buffer, valueBuffer);
+
+ xercesc::XMLString::release(&valueBuffer);
+ }
+
xercesc::XMLString::release(&buffer);
buffer = xercesc::XMLString::transcode(p.filename().string().data());
xercesc::DOMText* const textNode = domDocument->createTextNode(buffer);
xercesc::XMLString::release(&buffer);
- fileNode->appendChild(textNode);
- rootNode->appendChild(fileNode);
+ itemNode->appendChild(textNode);
+ rootNode->appendChild(itemNode);
});
return executionContext.getXObjectFactory().createNodeSet(