LCOV - code coverage report
Current view: top level - src/ar/internal/files - filesystem_file.cpp (source / functions) Hit Total Coverage
Test: ar-cpp code coverage Lines: 15 15 100.0 %
Date: 2017-12-27 13:15:38 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : ///
       2             : /// @file      ar/internal/files/filesystem_file.cpp
       3             : /// @copyright (c) 2015 by Petr Zemek (s3rvac@gmail.com) and contributors
       4             : /// @license   MIT, see the @c LICENSE file for more details
       5             : /// @brief     Implementation of the file stored in a filesystem.
       6             : ///
       7             : 
       8             : #include "ar/internal/files/filesystem_file.h"
       9             : #include "ar/internal/utilities/os.h"
      10             : 
      11             : namespace ar {
      12             : namespace internal {
      13             : 
      14             : ///
      15             : /// Constructs a file.
      16             : ///
      17             : /// @param[in] path Path to the file in a filesystem.
      18             : ///
      19           3 : FilesystemFile::FilesystemFile(const std::string& path):
      20           3 :     path{path}, name{fileNameFromPath(path)} {}
      21             : 
      22             : ///
      23             : /// Constructs a file with a custom name.
      24             : ///
      25             : /// @param[in] path Path to the file in a filesystem.
      26             : /// @param[in] name Name to be used as the file's name.
      27             : ///
      28           3 : FilesystemFile::FilesystemFile(const std::string& path,
      29           3 :         const std::string& name):
      30           3 :     path{path}, name{name} {}
      31             : 
      32             : FilesystemFile::~FilesystemFile() = default;
      33             : 
      34           4 : std::string FilesystemFile::getName() const {
      35           4 :     return name;
      36             : }
      37             : 
      38           1 : std::string FilesystemFile::getContent() {
      39           1 :     return readFile(path);
      40             : }
      41             : 
      42           1 : void FilesystemFile::saveCopyTo(const std::string& directoryPath) {
      43           1 :     saveCopyTo(directoryPath, name);
      44           1 : }
      45             : 
      46           1 : void FilesystemFile::saveCopyTo(const std::string& directoryPath,
      47             :         const std::string& name) {
      48           1 :     copyFile(path, joinPaths(directoryPath, name));
      49           1 : }
      50             : 
      51             : } // namespace internal
      52             : } // namespace ar

Generated by: LCOV version 1.13