Changeset dc62550


Ignore:
Timestamp:
11/10/18 22:30:26 (2 years ago)
Author:
Jacob van Walraven <jacobvw@…>
Branches:
develop
Children:
ccb2507
Parents:
acffeb8
Message:

Print a more suitable error when the input URI (file) is not found

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    r47d4f8c rdc62550  
    307307        TRACE_ERR_UNSUPPORTED_COMPRESS  = -11,
    308308        /** Wandio has returned an error */
    309         TRACE_ERR_WANDIO_FAILED = -12 
     309        TRACE_ERR_WANDIO_FAILED = -12,
     310        /** Input URI (file) not found */
     311        TRACE_ERR_URI_NOT_FOUND = -13 
    310312};
    311313
  • lib/trace.c

    r47d4f8c rdc62550  
    305305                guess_format(libtrace,uri);
    306306                if (!libtrace->format) {
    307                         trace_set_err(libtrace,TRACE_ERR_BAD_FORMAT,"Unable to guess format (%s)",uri);
     307                        /* Check if the file exists */
     308                        FILE *file;
     309                        if(!(file=fopen(uri, "r"))) {
     310                                trace_set_err(libtrace,TRACE_ERR_URI_NOT_FOUND,"Unable to find URI (%s)",uri);
     311                        } else {
     312                                fclose(file);
     313                                trace_set_err(libtrace,TRACE_ERR_BAD_FORMAT,"Unable to guess format (%s)",uri);
     314                        }
    308315                        return libtrace;
    309316                }
Note: See TracChangeset for help on using the changeset viewer.