Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:12

0001 /*
0002  * This File is part of Davix, The IO library for HTTP based protocols
0003  * Copyright (C) CERN 2013
0004  * Author: Adrien Devresse <adrien.devresse@cern.ch>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020 */
0021 
0022 #ifndef DAVIX_FILE_TYPES_HPP
0023 #define DAVIX_FILE_TYPES_HPP
0024 
0025 #include <memory>
0026 #include <utils/davix_types.hpp>
0027 #include <utils/davix_uri.hpp>
0028 
0029 /**
0030   @file davix_file_types.hpp
0031   @author Devresse Adrien
0032 
0033 
0034   @brief davix file related type declarations
0035 */
0036 
0037 
0038 // file descriptor declaration
0039 struct Davix_dir_handle;
0040 struct Davix_fd;
0041 
0042 typedef struct Davix_dir_handle DAVIX_DIR;
0043 typedef struct Davix_fd DAVIX_FD;
0044 
0045 namespace Davix{
0046 
0047 
0048 /// @struct DavIOVecInput
0049 /// @brief input parameters for vector operations in Davix
0050 struct DAVIX_EXPORT DavIOVecInput{
0051     void* diov_buffer;                    /**< buffer, in case of read : destination buffer, in case of write : source buffer */
0052     dav_off_t diov_offset;                /**< initial offset taken from the source */
0053     dav_size_t diov_size;                 /**< size of the data requested */
0054 };
0055 
0056 /// @struct DavIOVecOuput
0057 /// @brief result of vector operations in Davix
0058 struct DAVIX_EXPORT DavIOVecOuput{
0059     void* diov_buffer;                    /**< pointer to the buffer used for this fragment */
0060     dav_ssize_t diov_size;                /**< size of the data returned, -1 if error */
0061 };
0062 
0063 
0064 /// @enum advise_t
0065 /// Information about the next type of operation executed
0066 /// AdviseAuto : default operation, no optimization
0067 /// AdviseSequentialRead : optimize next operation for sequential read/write
0068 /// AdviseRandomRead: optimize next operation for random position read/write
0069 enum DAVIX_EXPORT advise_t{
0070     AdviseAuto=0x00,
0071     AdviseSequential,
0072     AdviseRandom,
0073 
0074 };
0075 
0076 ///
0077 /// @brief QuotaInfo struct
0078 /// @struct QuotaInfo
0079 /// handler to retrieve quota information
0080 ///
0081 
0082 class QuotaInfoHandler;
0083 
0084 class QuotaInfo {
0085 friend class QuotaInfoHandler;
0086 public:
0087     struct Internal;
0088     QuotaInfo();
0089     ~QuotaInfo();
0090     dav_size_t getUsedBytes();
0091     dav_size_t getFreeSpace();
0092 private:
0093     std::shared_ptr<Internal> d_ptr;
0094 };
0095 
0096 
0097 ///
0098 /// @brief StatInfo struct
0099 /// @struct StatInfo
0100 /// container for base file meta-data, plateform agnostic stat struct
0101 ///
0102 struct StatInfo{
0103     StatInfo(): size(0), nlink(0), mode(0), atime(0), mtime(0), ctime(0), owner(0), group(0) {
0104     }
0105 
0106     /// size in bytes of the resource
0107     dav_size_t size;
0108     /// number of links to the resource
0109     /// optional
0110     dav_ssize_t nlink;
0111     /// POSIX rights of the resource
0112     /// optional, supported with some Webdav servers
0113     mode_t mode;
0114     /// access time
0115     time_t atime;
0116     /// modification time
0117     time_t mtime;
0118     /// creation time
0119     time_t ctime;
0120     /// owner UID
0121     uid_t owner;
0122     /// group UID
0123     gid_t group;
0124 
0125     /// struct converter from POSIX stat
0126     inline void fromPosixStat(const struct stat & st){
0127         mode = static_cast<mode_t>(st.st_mode);
0128         atime = static_cast<time_t>(st.st_atime);
0129         mtime = static_cast<time_t>(st.st_mtime);
0130         ctime = static_cast<time_t>(st.st_ctime);
0131         size =  static_cast<dav_size_t>(st.st_size);
0132         nlink = static_cast<dav_size_t>(st.st_nlink);
0133         owner = static_cast<uid_t>(st.st_uid);
0134         group = static_cast<gid_t>(st.st_gid);
0135     }
0136 
0137     /// struct converter to POSIX stat
0138     inline struct stat & toPosixStat(struct stat & st){
0139         st.st_mode = static_cast<mode_t>(mode);
0140         st.st_atime = static_cast<time_t>(atime);
0141         st.st_mtime = static_cast<time_t>(mtime);
0142         st.st_ctime = static_cast<time_t>(ctime);
0143         st.st_size =  static_cast<off_t>(size);
0144         st.st_nlink = static_cast<nlink_t>(nlink);
0145         st.st_uid = static_cast<uid_t>(owner);
0146         st.st_gid = static_cast<gid_t>(group);
0147         return st;
0148     }
0149 };
0150 
0151 
0152 
0153 } // Davix
0154 
0155 
0156 #endif // DAVIX_FILE_TYPES_HPP