diff --git a/common/ArchiveFileStatus.cpp b/common/ArchiveFileStatus.cpp index f54658a237738d706988bc878a7f22ea67bef4f3..5ab93df6a97293214942f084f20cef73ad44b1cf 100644 --- a/common/ArchiveFileStatus.cpp +++ b/common/ArchiveFileStatus.cpp @@ -22,7 +22,8 @@ // constructor //------------------------------------------------------------------------------ cta::ArchiveFileStatus::ArchiveFileStatus(): - m_mode(0) { + m_mode(0), + m_size(0) { } //------------------------------------------------------------------------------ @@ -31,10 +32,12 @@ cta::ArchiveFileStatus::ArchiveFileStatus(): cta::ArchiveFileStatus::ArchiveFileStatus( const UserIdentity &owner, const mode_t mode, + const uint64_t size, const Checksum &checksum, const std::string &storageClassName): m_owner(owner), m_mode(mode), + m_size(size), m_checksum(checksum), m_storageClassName(storageClassName) { } @@ -53,6 +56,13 @@ mode_t cta::ArchiveFileStatus::getMode() const throw() { return m_mode; } +//------------------------------------------------------------------------------ +// getSize +//------------------------------------------------------------------------------ +uint64_t cta::ArchiveFileStatus::getSize() const throw() { + return m_size; +} + //------------------------------------------------------------------------------ // getChecksum //------------------------------------------------------------------------------ diff --git a/common/ArchiveFileStatus.hpp b/common/ArchiveFileStatus.hpp index 8403f26f183db6b05199fafda47806fa0954a337..6bcc83255791f5e09cf365684d25a988710f29ac 100644 --- a/common/ArchiveFileStatus.hpp +++ b/common/ArchiveFileStatus.hpp @@ -21,12 +21,13 @@ #include "common/Checksum.hpp" #include "common/UserIdentity.hpp" +#include <stdint.h> #include <string> namespace cta { /** - * The status of a file or a directory. + * The status of a file or a directory entry in the archive namespace. */ class ArchiveFileStatus { public: @@ -43,6 +44,7 @@ public: * * @param owner The identity of the owner. * @param mode The mode bits of the file or directory. + * @param size The size of the file in bytes. * @param checksum The checksum of the file. * @param storageClassName The name of the file or directory's storage class. * An empty string indicates no storage class. @@ -50,6 +52,7 @@ public: ArchiveFileStatus( const UserIdentity &owner, const mode_t mode, + const uint64_t size, const Checksum &checksum, const std::string &storageClassName); @@ -65,6 +68,13 @@ public: */ mode_t getMode() const throw(); + /** + * Returns the size of the file in bytes. + * + * @return The size of the file in bytes. + */ + uint64_t getSize() const throw(); + /** * Returns the checksum of the file. * @@ -100,6 +110,13 @@ private: */ mode_t m_mode; + /** + * Returns the size of the file in bytes. + * + * @return The size of the file in bytes. + */ + uint64_t m_size; + /** * The checksum of the file. */ diff --git a/remotens/CMakeLists.txt b/remotens/CMakeLists.txt index e69899210c8ef1c5813e81524878587daa82dadf..d91e95a1b29055289de52ee1023642d194aeb091 100644 --- a/remotens/CMakeLists.txt +++ b/remotens/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required (VERSION 2.6) set (CTA_REMOTENS_SRC_FILES EosNS.cpp MockRemoteNS.cpp + RemoteFileStatus.cpp RemoteNS.cpp RemoteNSDispatcher.cpp) diff --git a/remotens/RemoteFileStatus.cpp b/remotens/RemoteFileStatus.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3bb96e47fed5121f3c854be1393ca86ede05faee --- /dev/null +++ b/remotens/RemoteFileStatus.cpp @@ -0,0 +1,86 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2015 CERN + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "common/RemoteFileStatus.hpp" + +//------------------------------------------------------------------------------ +// constructor +//------------------------------------------------------------------------------ +cta::RemoteFileStatus::RemoteFileStatus(): + m_mode(0), + m_size(0) { +} + +//------------------------------------------------------------------------------ +// constructor +//------------------------------------------------------------------------------ +cta::RemoteFileStatus::RemoteFileStatus( + const UserIdentity &owner, + const mode_t mode, + const uint64_t size, + const Checksum &checksum, + const std::string &storageClassName): + m_owner(owner), + m_mode(mode), + m_size(size), + m_checksum(checksum), + m_storageClassName(storageClassName) { +} + +//------------------------------------------------------------------------------ +// getOwner +//------------------------------------------------------------------------------ +const cta::UserIdentity &cta::RemoteFileStatus::getOwner() const throw() { + return m_owner; +} + +//------------------------------------------------------------------------------ +// getMode +//------------------------------------------------------------------------------ +mode_t cta::RemoteFileStatus::getMode() const throw() { + return m_mode; +} + +//------------------------------------------------------------------------------ +// getSize +//------------------------------------------------------------------------------ +uint64_t cta::RemoteFileStatus::getSize() const throw() { + return m_size; +} + +//------------------------------------------------------------------------------ +// getChecksum +//------------------------------------------------------------------------------ +const cta::Checksum &cta::RemoteFileStatus::getChecksum() const throw() { + return m_checksum; +} + +//------------------------------------------------------------------------------ +// setStorageClassName +//------------------------------------------------------------------------------ +void cta::RemoteFileStatus::setStorageClassName( + const std::string &storageClassName) { + m_storageClassName = storageClassName; +} + +//------------------------------------------------------------------------------ +// getStorageClassName +//------------------------------------------------------------------------------ +const std::string &cta::RemoteFileStatus::getStorageClassName() const throw() { + return m_storageClassName; +} diff --git a/remotens/RemoteFileStatus.hpp b/remotens/RemoteFileStatus.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ca995dda3da2a52c3f871625a5b1607f2910ce04 --- /dev/null +++ b/remotens/RemoteFileStatus.hpp @@ -0,0 +1,93 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2015 CERN + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "common/UserIdentity.hpp" + +#include <stdint.h> +#include <string> + +namespace cta { + +/** + * The status of a remote file or a directory. + */ +class RemoteFileStatus { +public: + + /** + * Constructor. + * + * Initialises all integer member-variables to 0. + */ + RemoteFileStatus(); + + /** + * Constructor. + * + * @param owner The identity of the owner. + * @param mode The mode bits of the file or directory. + * @param size The size of the file in bytes. + */ + RemoteFileStatus( + const UserIdentity &owner, + const mode_t mode, + const uint64_t size); + + /** + * Returns the identity of the owner. + */ + const UserIdentity &getOwner() const throw(); + + /** + * Returns the mode bits of the directory entry. + * + * @return The mode bits of the directory entry. + */ + mode_t getMode() const throw(); + + /** + * Returns the size of the file in bytes. + * + * @return The size of the file in bytes. + */ + uint64_t getSize() const throw(); + +private: + + /** + * The identity of the owner. + */ + UserIdentity m_owner; + + /** + * The mode bits of the directory entry. + */ + mode_t m_mode; + + /** + * Returns the size of the file in bytes. + * + * @return The size of the file in bytes. + */ + uint64_t m_size; + +}; // class RemoteFileStatus + +} // namespace cta