LCOV - code coverage report
Current view: top level - u8stream/source/u8dir - u8dir_file.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 17 17 100.0 %
Date: 2024-10-26 21:44:38 Functions: 1 1 100.0 %

          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          15 : u8_error_t u8dir_file_remove( u8dir_file_t this_ )
      11             : {
      12          15 :     U8_TRACE_BEGIN();
      13          15 :     assert( this_ != NULL );
      14          15 :     u8_error_t err = U8_ERROR_NONE;
      15             : 
      16          15 :     const int remove_err = remove( this_ );
      17          15 :     if ( 0 != remove_err )
      18             :     {
      19             :         /* This error may have happened on purpose or by an unexpected condition */
      20           3 :         if (errno == ENOENT)
      21             :         {
      22           2 :             U8_TRACE_INFO_STR( "tried to remove non-existing file:", this_ );
      23           2 :             U8_LOG_EVENT("remove() called on non-existing file.");
      24           2 :             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          12 :         U8_TRACE_INFO_STR( "removed file:", this_ );
      36          12 :         U8_LOG_EVENT("remove() removed a file.");
      37             :     }
      38             : 
      39          15 :     U8_TRACE_END_ERR(err);
      40          15 :     return err;
      41             : }
      42             : 
      43             : 
      44             : /*
      45             : Copyright 2022-2024 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 1.16