Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:31

0001 /*************************************************************************
0002  * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0007  *************************************************************************/
0008 
0009 #ifndef ROOT7_Browsabl_RSysFileItem
0010 #define ROOT7_Browsabl_RSysFileItem
0011 
0012 #include <ROOT/Browsable/RItem.hxx>
0013 
0014 namespace ROOT {
0015 namespace Browsable {
0016 
0017 
0018 class RSysDirLevelIter;
0019 
0020 /** \class RSysFileItem
0021 \ingroup rbrowser
0022 \brief Representation of single item in the file browser
0023 */
0024 
0025 class RSysFileItem : public RItem {
0026 
0027 friend class RSysDirLevelIter;
0028 
0029 private:
0030    // internal data, used for generate directory list
0031    int type{0};             ///<! file type
0032    int uid{0};              ///<! file uid
0033    int gid{0};              ///<! file gid
0034    bool islink{false};      ///<! true if symbolic link
0035    bool isdir{false};       ///<! true if directory
0036    long modtime{0};         ///<! modification time
0037    int64_t size{0};         ///<! file size
0038 
0039 protected:
0040    // this is part for browser, visible for I/O
0041    std::string ftype;    ///< file attributes
0042    std::string fuid;     ///< user id
0043    std::string fgid;     ///< group id
0044 
0045 public:
0046 
0047    /** Default constructor */
0048    RSysFileItem() = default;
0049 
0050    RSysFileItem(const std::string &_name, int _nchilds) : RItem(_name, _nchilds) {}
0051 
0052    // should be here, one needs virtual table for correct streaming of RRootBrowserReply
0053    virtual ~RSysFileItem() = default;
0054 
0055    void SetType(const std::string &_type) { ftype  = _type; }
0056    void SetUid(const std::string &_uid) { fuid  = _uid; }
0057    void SetGid(const std::string &_gid) { fgid  = _gid; }
0058 
0059    const std::string &GetType() const { return ftype; }
0060    const std::string &GetUid() const { return fuid; }
0061    const std::string &GetGid() const { return fgid; }
0062 
0063 
0064    // only subdir is folder for files items
0065    bool IsFolder() const override { return isdir; }
0066 
0067    // return true for hidden files
0068    bool IsHidden() const override
0069    {
0070       auto &n = GetName();
0071       if ((n.length() == 0) || (n[0] != '.')) return false;
0072       return (n != ".") && (n != "..");
0073    }
0074 
0075    bool Compare(const RItem *b, const std::string &method) const override
0076    {
0077       if (IsFolder() != b->IsFolder())
0078          return IsFolder();
0079 
0080       if (method == "size") {
0081          auto fb = dynamic_cast<const RSysFileItem *> (b);
0082          if (fb)
0083             return size < fb->size;
0084       }
0085 
0086       return GetName() < b->GetName();
0087    }
0088 };
0089 
0090 } // namespace Browsable
0091 } // namespace ROOT
0092 
0093 
0094 #endif