LCOV - code coverage report
Current view: top level - zipios++ - filepath.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2015-04-12 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : #ifndef ZIPIOS_FILEPATH_HPP
       3             : #define ZIPIOS_FILEPATH_HPP
       4             : 
       5             : /*
       6             :   Zipios++ - a small C++ library that provides easy access to .zip files.
       7             : 
       8             :   Copyright (C) 2000-2007  Thomas Sondergaard
       9             :   Copyright (C) 2015  Made to Order Software Corporation
      10             : 
      11             :   This library is free software; you can redistribute it and/or
      12             :   modify it under the terms of the GNU Lesser General Public
      13             :   License as published by the Free Software Foundation; either
      14             :   version 2 of the License, or (at your option) any later version.
      15             : 
      16             :   This library is distributed in the hope that it will be useful,
      17             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      19             :   Lesser General Public License for more details.
      20             : 
      21             :   You should have received a copy of the GNU Lesser General Public
      22             :   License along with this library; if not, write to the Free Software
      23             :   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      24             : */
      25             : 
      26             : /** \file
      27             :  * \brief Define the zipios::FilePath class.
      28             :  *
      29             :  * zipios::FilePath is used to manage paths and filenames to files
      30             :  * and directories.
      31             :  *
      32             :  * It is used by the zipios::FileEntry to represent the virtual filename
      33             :  * that the virtual file has.
      34             :  */
      35             : 
      36             : #include "zipios++/zipios-config.hpp"
      37             : 
      38             : #include <ctime>
      39             : #include <string>
      40             : 
      41             : 
      42             : namespace zipios
      43             : {
      44             : 
      45             : 
      46     2027494 : class FilePath
      47             : {
      48             : public:
      49             :                         FilePath(std::string const& path = "");
      50             : 
      51             :                         operator std::string () const;
      52             :     FilePath&           operator = (std::string const& path);
      53             :     FilePath            operator + (FilePath const& name) const;
      54             :     bool                operator == (char const *rhs) const;
      55             :     friend bool         operator == (char const *lhs, FilePath const& rhs);
      56             :     bool                operator == (std::string const& rhs) const;
      57             :     friend bool         operator == (std::string const& lhs, FilePath const& rhs);
      58             :     bool                operator == (FilePath const& rhs) const;
      59             :     // TBD: add all the other comparison operators for completeness
      60             :     std::string         filename() const;
      61             :     size_t              length() const;
      62             :     size_t              size() const;
      63             :     bool                exists() const;
      64             :     bool                isRegular() const;
      65             :     bool                isDirectory() const;
      66             :     bool                isCharSpecial() const;
      67             :     bool                isBlockSpecial() const;
      68             :     bool                isSocket() const;
      69             :     bool                isFifo() const;
      70             :     size_t              fileSize() const;
      71             :     std::time_t         lastModificationTime() const;
      72             : 
      73             : private:
      74             :     void                check() const;
      75             : 
      76             :     std::string         m_path;
      77             :     mutable os_stat_t   m_stat;
      78             :     mutable bool        m_checked = false;
      79             :     mutable bool        m_exists = false;
      80             : };
      81             : 
      82             : 
      83             : std::ostream& operator << (std::ostream& os, FilePath const& path);
      84             : 
      85             : 
      86             : } // zipios namespace
      87             : 
      88             : // Local Variables:
      89             : // mode: cpp
      90             : // indent-tabs-mode: nil
      91             : // c-basic-offset: 4
      92             : // tab-width: 4
      93             : // End:
      94             : 
      95             : // vim: ts=4 sw=4 et
      96             : #endif

Generated by: LCOV version 1.10