Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:39

0001 //------------------------------------------------------------------------------
0002 // Copyright (c) 2014 by European Organization for Nuclear Research (CERN)
0003 // Author: Lukasz Janyst <ljanyst@cern.ch>
0004 //------------------------------------------------------------------------------
0005 // This file is part of the XRootD software suite.
0006 //
0007 // XRootD is free software: you can redistribute it and/or modify
0008 // it under the terms of the GNU Lesser General Public License as published by
0009 // the Free Software Foundation, either version 3 of the License, or
0010 // (at your option) any later version.
0011 //
0012 // XRootD is distributed in the hope that it will be useful,
0013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 // GNU General Public License for more details.
0016 //
0017 // You should have received a copy of the GNU Lesser General Public License
0018 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
0019 //
0020 // In applying this licence, CERN does not waive the privileges and immunities
0021 // granted to it by virtue of its status as an Intergovernmental Organization
0022 // or submit itself to any jurisdiction.
0023 //------------------------------------------------------------------------------
0024 
0025 #ifndef __XRD_CL_FILE_SYSTEM_UTILS_HH__
0026 #define __XRD_CL_FILE_SYSTEM_UTILS_HH__
0027 
0028 #include "XrdCl/XrdClXRootDResponses.hh"
0029 
0030 #include <string>
0031 #include <cstdint>
0032 #include <memory>
0033 
0034 namespace XrdCl
0035 {
0036   class FileSystem;
0037 
0038   //----------------------------------------------------------------------------
0039   //! A container for file system utility functions that do not belong in
0040   //! FileSystem
0041   //----------------------------------------------------------------------------
0042   class FileSystemUtils
0043   {
0044       //------------------------------------------------------------------------
0045       // Forward declaration for PIMPL
0046       //------------------------------------------------------------------------
0047       struct SpaceInfoImpl;
0048 
0049     public:
0050       //------------------------------------------------------------------------
0051       //! Container for space information
0052       //------------------------------------------------------------------------
0053       class SpaceInfo
0054       {
0055         public:
0056           SpaceInfo( uint64_t total, uint64_t free, uint64_t used,
0057                      uint64_t largestChunk );
0058 
0059           ~SpaceInfo();
0060 
0061           //--------------------------------------------------------------------
0062           //! Amount of total space in MB
0063           //--------------------------------------------------------------------
0064           uint64_t GetTotal() const;
0065 
0066           //--------------------------------------------------------------------
0067           //! Amount of free space in MB
0068           //--------------------------------------------------------------------
0069           uint64_t GetFree() const;
0070 
0071           //--------------------------------------------------------------------
0072           //! Amount of used space in MB
0073           //--------------------------------------------------------------------
0074           uint64_t GetUsed() const;
0075 
0076           //--------------------------------------------------------------------
0077           //! Largest single chunk of free space
0078           //--------------------------------------------------------------------
0079           uint64_t GetLargestFreeChunk() const;
0080 
0081         private:
0082           std::unique_ptr<SpaceInfoImpl> pImpl;
0083       };
0084 
0085       //------------------------------------------------------------------------
0086       //! Recursively get space information for given path
0087       //------------------------------------------------------------------------
0088       static XRootDStatus GetSpaceInfo( SpaceInfo         *&result,
0089                                         FileSystem         *fs,
0090                                         const std::string  &path );
0091   };
0092 }
0093 
0094 #endif // __XRD_CL_FILE_SYSTEM_UTILS HH__