Remove a file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filepath | |||
logical, | intent(out), | optional | :: | success |
subroutine sys_remove_file(filepath, success) character(len=*), intent(in) :: filepath logical, intent(out), optional :: success character(len=512) :: command integer :: exitstat if (get_os_type() == OS_WINDOWS) then command = 'del /f /q "'//trim(escape_shell_arg(filepath))//'" 2>nul' else command = 'rm -f "'//trim(escape_shell_arg(filepath))//'" 2>/dev/null' end if call execute_command_line(command, exitstat=exitstat) if (present(success)) success = (exitstat == 0) end subroutine sys_remove_file