Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RSysFileItem.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_Browsabl_RSysFileItem
10#define ROOT7_Browsabl_RSysFileItem
11
13
14namespace ROOT {
15namespace Browsable {
16
17
18class RSysDirLevelIter;
19
20/** \class RSysFileItem
21\ingroup rbrowser
22\brief Representation of single item in the file browser
23*/
24
25class RSysFileItem : public RItem {
26
27friend class RSysDirLevelIter;
28
29private:
30 // internal data, used for generate directory list
31 int type{0}; ///<! file type
32 int uid{0}; ///<! file uid
33 int gid{0}; ///<! file gid
34 bool islink{false}; ///<! true if symbolic link
35 bool isdir{false}; ///<! true if directory
36 long modtime{0}; ///<! modification time
37 int64_t size{0}; ///<! file size
38
39protected:
40 // this is part for browser, visible for I/O
41 std::string ftype; ///< file attributes
42 std::string fuid; ///< user id
43 std::string fgid; ///< group id
44
45public:
46
47 /** Default constructor */
48 RSysFileItem() = default;
49
50 RSysFileItem(const std::string &_name, int _nchilds) : RItem(_name, _nchilds) {}
51
52 // should be here, one needs virtual table for correct streaming of RRootBrowserReply
53 virtual ~RSysFileItem() = default;
54
55 void SetType(const std::string &_type) { ftype = _type; }
56 void SetUid(const std::string &_uid) { fuid = _uid; }
57 void SetGid(const std::string &_gid) { fgid = _gid; }
58
59 const std::string &GetType() const { return ftype; }
60 const std::string &GetUid() const { return fuid; }
61 const std::string &GetGid() const { return fgid; }
62
63
64 // only subdir is folder for files items
65 bool IsFolder() const override { return isdir; }
66
67 // return true for hidden files
68 bool IsHidden() const override
69 {
70 auto &n = GetName();
71 if ((n.length() == 0) || (n[0] != '.')) return false;
72 return (n != ".") && (n != "..");
73 }
74
75 bool Compare(const RItem *b, const std::string &method) const override
76 {
77 if (IsFolder() != b->IsFolder())
78 return IsFolder();
79
80 if (method == "size") {
81 auto fb = dynamic_cast<const RSysFileItem *> (b);
82 if (fb)
83 return size < fb->size;
84 }
85
86 return GetName() < b->GetName();
87 }
88};
89
90} // namespace Browsable
91} // namespace ROOT
92
93
94#endif
#define b(i)
Definition RSha256.hxx:100
Representation of single item in the browser.
Definition RItem.hxx:23
const std::string & GetName() const
Definition RItem.hxx:40
Iterator over files in in sub-directory.
Definition RSysFile.cxx:63
Representation of single item in the file browser.
const std::string & GetUid() const
std::string ftype
file attributes
void SetType(const std::string &_type)
const std::string & GetType() const
void SetUid(const std::string &_uid)
RSysFileItem(const std::string &_name, int _nchilds)
RSysFileItem()=default
Default constructor.
bool Compare(const RItem *b, const std::string &method) const override
bool isdir
! true if directory
const std::string & GetGid() const
void SetGid(const std::string &_gid)
virtual ~RSysFileItem()=default
bool IsHidden() const override
bool islink
! true if symbolic link
long modtime
! modification time
bool IsFolder() const override
const Int_t n
Definition legend1.C:16
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...