diff --git a/include/villas/advio.h b/include/villas/advio.h index 415721aaa..a1741a9f9 100644 --- a/include/villas/advio.h +++ b/include/villas/advio.h @@ -61,6 +61,9 @@ typedef struct advio AFILE; #define auri(af) ((af)->uri) #define ahash(af) ((af)->hash) +/** Check if a URI is pointing to a local file. */ +int aislocal(const char *uri); + AFILE *afopen(const char *url, const char *mode); int afclose(AFILE *file); @@ -72,7 +75,6 @@ int afseek(AFILE *file, long offset, int origin); void arewind(AFILE *file); /** Download contens from remote file - * * * @param resume Do a partial download and append to the local file */ diff --git a/lib/advio.c b/lib/advio.c index 25206d403..02b955eca 100644 --- a/lib/advio.c +++ b/lib/advio.c @@ -169,6 +169,11 @@ static int advio_xferinfo(void *p, curl_off_t dl_total_bytes, curl_off_t dl_byte return 0; } +int aislocal(const char *uri) +{ + return access(uri, F_OK) != -1; +} + AFILE * afopen(const char *uri, const char *mode) { int ret; @@ -184,7 +189,7 @@ AFILE * afopen(const char *uri, const char *mode) if (!af->uri) goto out2; } - else { + else { /* Open local file by prepending file:// schema. */ if (strlen(uri) <= 1) return NULL; @@ -416,6 +421,7 @@ int adownload(AFILE *af, int resume) case CURLE_FILE_COULDNT_READ_FILE: case CURLE_TFTP_NOTFOUND: case CURLE_REMOTE_FILE_NOT_FOUND: + info("File does not exist."); goto notexist; /* If libcurl does not know the protocol, we will try it with the stdio */ @@ -425,7 +431,7 @@ int adownload(AFILE *af, int resume) return -1; default: - error("ADVIO: Failed to download file: %s: %s", af->uri, curl_easy_strerror(res)); + error("Failed to download file: %s: %s", af->uri, curl_easy_strerror(res)); return -1; }