Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsFileNode.cpp
Go to the documentation of this file.
1 
14 #include "WsFileNode.h"
15 
16 WsFileNode::WsFileNode(const path& fullPath, const path& rootPath): WsNode(fullPath, rootPath)
17 {
18 }
19 
21 {
22 }
23 
24 const set<string> WsFileNode::getGroups()
25 {
26  /* Get the groups from parent because this is a WsFileNode */
27  if ( !m_parent.expired() ) {
28  NodePtr parent = m_parent.lock();
29  return dynamic_cast<WsDirNode*>(parent.get())->getGroups();
30  }
31  return set<string>();
32 }
33 
34 bool WsFileNode::isAllowed(const set<string>& gids)
35 {
36  /* Currently, access to a file is allowed if access is granted to its */
37  /* containing directory */
38  if ( !m_parent.expired() ) {
39  NodePtr parent = m_parent.lock();
40  return dynamic_cast<WsDirNode*>(parent.get())->isAllowed(gids);
41  }
42  return false;
43 }
44 
50 {
51  string val = m_properties.get()->get("global", "in_menu", "true");
52  if (val == "true")
53  return true;
54  return false;
55 }
56 
58 {
59  string date = m_properties.get()->get("global", "publish_date", "");
60  return date == "" ? boost::lexical_cast<string>(m_modifyTime) : date;
61 }
62 
63 const string WsFileNode::getAuthor()
64 {
65  return m_properties.get()->get("global", "author", "");
66 }
67 
68 const uintmax_t WsFileNode::getSize()
69 {
70  return m_size;
71 }
72 
74 {
75  return false;
76 }
77 
79 {
80  return true;
81 }
boost::shared_ptr< WsAbstractNode > NodePtr
Reprensents a Directory on disk.
Definition: WsDirNode.h:25
bool isRegularFile()
Definition: WsFileNode.cpp:78
bool isAllowed(const std::set< string > &gids)
Return true or false whether the gids are allowed or no.
Definition: WsFileNode.cpp:34
Represents a node on disk.
Definition: WsNode.h:27
bool isDirectory()
Definition: WsFileNode.cpp:73
NodePropertiesPtr m_properties
Definition: WsNode.h:218
const uintmax_t getSize()
return the size of the file
Definition: WsFileNode.cpp:68
const string getAuthor()
returns the author name.
Definition: WsFileNode.cpp:63
bool getDisplayInMenu()
returns true if the item should be displayed in the menu. This value is set in the configuration file...
Definition: WsFileNode.cpp:49
uintmax_t m_size
time_t m_modifyTime
Definition: WsNode.h:226
const set< string > getGroups()
returns the list of the groups allowed to access this node
Definition: WsFileNode.cpp:24
const string getPublishDate()
returns the publish date of the file
Definition: WsFileNode.cpp:57