LCOV - code coverage report
Current view: top level - source/common/filesystem - file_shared_impl.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 2 25 8.0 %
Date: 2024-01-05 06:35:25 Functions: 2 6 33.3 %

          Line data    Source code
       1             : #include "source/common/filesystem/file_shared_impl.h"
       2             : 
       3             : #include <random>
       4             : 
       5             : #include "source/common/common/utility.h"
       6             : 
       7             : namespace Envoy {
       8             : namespace Filesystem {
       9             : 
      10           0 : Api::IoError::IoErrorCode IoFileError::getErrorCode() const {
      11           0 :   switch (errno_) {
      12           0 :   case HANDLE_ERROR_PERM:
      13           0 :     return IoErrorCode::Permission;
      14           0 :   case HANDLE_ERROR_INVALID:
      15           0 :     return IoErrorCode::BadFd;
      16           0 :   default:
      17           0 :     ENVOY_LOG_MISC(debug, "Unknown error code {} details {}", errno_, getErrorDetails());
      18           0 :     return IoErrorCode::UnknownError;
      19           0 :   }
      20           0 : }
      21             : 
      22           0 : std::string IoFileError::getErrorDetails() const { return errorDetails(errno_); }
      23             : 
      24         440 : bool FileSharedImpl::isOpen() const { return fd_ != INVALID_HANDLE; };
      25             : 
      26         307 : std::string FileSharedImpl::path() const { return filepath_and_type_.path_; };
      27             : 
      28           0 : DestinationType FileSharedImpl::destinationType() const { return filepath_and_type_.file_type_; };
      29             : 
      30           0 : std::string FileSharedImpl::generateTmpFilePath(absl::string_view path) {
      31           0 :   static std::random_device rd;
      32           0 :   static std::mt19937 gen(rd());
      33           0 :   static std::uniform_int_distribution<> distribution('A', 'Z');
      34           0 :   std::array<char, 8> out;
      35           0 :   for (int i = 0; i < 8; i++) {
      36           0 :     out[i] = distribution(gen);
      37           0 :   }
      38           0 :   return absl::StrCat(path, "/envoy_", absl::string_view{&out[0], out.size()}, ".tmp");
      39           0 : }
      40             : 
      41             : } // namespace Filesystem
      42             : } // namespace Envoy

Generated by: LCOV version 1.15