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 Experimental {
16namespace Browsable {
17
18
19class RSysDirLevelIter;
20
21/** \class RSysFileItem
22\ingroup rbrowser
23\brief Representation of single item in the file browser
24*/
25
26class RSysFileItem : public RItem {
27
28friend class RSysDirLevelIter;
29
30private:
31 // internal data, used for generate directory list
32 int type{0}; ///<! file type
33 int uid{0}; ///<! file uid
34 int gid{0}; ///<! file gid
35 bool islink{false}; ///<! true if symbolic link
36 bool isdir{false}; ///<! true if directory
37 long modtime{0}; ///<! modification time
38 int64_t size{0}; ///<! file size
39
40protected:
41 // this is part for browser, visible for I/O
42 std::string ftype; ///< file attributes
43 std::string fuid; ///< user id
44 std::string fgid; ///< group id
45
46public:
47
48 /** Default constructor */
49 RSysFileItem() = default;
50
51 RSysFileItem(const std::string &_name, int _nchilds) : RItem(_name, _nchilds) {}
52
53 // should be here, one needs virtual table for correct streaming of RRootBrowserReply
54 virtual ~RSysFileItem() = default;
55
56 void SetType(const std::string &_type) { ftype = _type; }
57 void SetUid(const std::string &_uid) { fuid = _uid; }
58 void SetGid(const std::string &_gid) { fgid = _gid; }
59
60 const std::string &GetType() const { return ftype; }
61 const std::string &GetUid() const { return fuid; }
62 const std::string &GetGid() const { return fgid; }
63
64
65 // only subdir is folder for files items
66 bool IsFolder() const override { return isdir; }
67
68 // return true for hidden files
69 bool IsHidden() const override
70 {
71 auto &n = GetName();
72 if ((n.length() == 0) || (n[0] != '.')) return false;
73 return (n != ".") && (n != "..");
74 }
75
76 bool Compare(const RItem *b, const std::string &method) const override
77 {
78 if (IsFolder() != b->IsFolder())
79 return IsFolder();
80
81 if (method == "size") {
82 auto fb = dynamic_cast<const RSysFileItem *> (b);
83 if (fb)
84 return size < fb->size;
85 }
86
87 return GetName() < b->GetName();
88 }
89};
90
91} // namespace Browsable
92} // namespace Experimental
93} // namespace ROOT
94
95
96#endif
#define b(i)
Definition RSha256.hxx:100
Representation of single item in the browser.
Definition RItem.hxx:24
const std::string & GetName() const
Definition RItem.hxx:41
Iterator over files in in sub-directory.
Definition RSysFile.cxx:64
Representation of single item in the file browser.
void SetUid(const std::string &_uid)
RSysFileItem(const std::string &_name, int _nchilds)
bool Compare(const RItem *b, const std::string &method) const override
void SetType(const std::string &_type)
void SetGid(const std::string &_gid)
RSysFileItem()=default
Default constructor.
const Int_t n
Definition legend1.C:16
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.