cleanup_temp_dir Subroutine

public subroutine cleanup_temp_dir(temp_dir)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: temp_dir

Source Code

    subroutine cleanup_temp_dir(temp_dir)
        character(len=*), intent(in) :: temp_dir
        integer :: ios

        if (len_trim(temp_dir) > 0) then
            if (get_os_type() == OS_WINDOWS) then
                ! Windows system - use rmdir command
            call execute_command_line('rmdir /s /q "'//trim(escape_quotes(temp_dir))// &
                                          '" 2>nul', exitstat=ios)
            else
                ! Unix/Linux system - use rm command
 call execute_command_line('rm -rf "'//trim(escape_quotes(temp_dir))//'"', exitstat=ios)
            end if
            ! Don't error on cleanup failure - just warn
            if (ios /= 0) then
                print *, 'Warning: Failed to cleanup temporary directory: '// &
                    trim(temp_dir)
            end if
        end if

    end subroutine cleanup_temp_dir