LCOV - code coverage report
Current view: top level - u8stream/source/u8dir - u8dir_file.c (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 100.0 % 17 17
Test Date: 2025-05-01 10:10:14 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /* File: u8dir_file.c; Copyright and License: see below */
       2              : 
       3              : #include "u8dir/u8dir_file.h"
       4              : #include "u8/u8_trace.h"
       5              : #include "u8/u8_log.h"
       6              : #include <stdio.h>
       7              : #include <stdbool.h>
       8              : #include <assert.h>
       9              : 
      10           20 : u8_error_t u8dir_file_remove( u8dir_file_t this_ )
      11              : {
      12           20 :     U8_TRACE_BEGIN();
      13           20 :     assert( this_ != NULL );
      14           20 :     u8_error_t err = U8_ERROR_NONE;
      15              : 
      16           20 :     const int remove_err = remove( this_ );
      17           20 :     if ( 0 != remove_err )
      18              :     {
      19              :         /* This error may have happened on purpose or by an unexpected condition */
      20            5 :         if (errno == ENOENT)
      21              :         {
      22            4 :             U8_TRACE_INFO_STR( "tried to remove non-existing file:", this_ );
      23            4 :             U8_LOG_EVENT("remove() called on non-existing file.");
      24            4 :             err |= U8_ERROR_FILE_ALREADY_REMOVED;
      25              :         }
      26              :         else
      27              :         {
      28            1 :             U8_TRACE_INFO_STR( "error at removing file:", this_ );
      29            1 :             U8_LOG_EVENT("remove() failed to remove a file.");
      30            1 :             err |= U8_ERROR_AT_FILE_WRITE;
      31              :         }
      32              :     }
      33              :     else
      34              :     {
      35           15 :         U8_TRACE_INFO_STR( "removed file:", this_ );
      36           15 :         U8_LOG_EVENT("remove() removed a file.");
      37              :     }
      38              : 
      39           20 :     U8_TRACE_END_ERR(err);
      40           20 :     return err;
      41              : }
      42              : 
      43              : 
      44              : /*
      45              : Copyright 2022-2025 Andreas Warnke
      46              : 
      47              : Licensed under the Apache License, Version 2.0 (the "License");
      48              : you may not use this file except in compliance with the License.
      49              : You may obtain a copy of the License at
      50              : 
      51              :     http://www.apache.org/licenses/LICENSE-2.0
      52              : 
      53              : Unless required by applicable law or agreed to in writing, software
      54              : distributed under the License is distributed on an "AS IS" BASIS,
      55              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      56              : See the License for the specific language governing permissions and
      57              : limitations under the License.
      58              : */
        

Generated by: LCOV version 2.0-1