X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Fctf%2Ffs-src%2Ffile.c;h=585faef876d6f6e03ebd1c0de1b283cf396af37d;hb=68b66a256a54d32992dfefeaad11eea88b7df234;hp=0d0ed7e0a21ddb66143260b05920c815028def25;hpb=cd00e1d36ebc9d77c1c69ac679f8af79196508e7;p=babeltrace.git diff --git a/plugins/ctf/fs-src/file.c b/plugins/ctf/fs-src/file.c index 0d0ed7e0..585faef8 100644 --- a/plugins/ctf/fs-src/file.c +++ b/plugins/ctf/fs-src/file.c @@ -25,31 +25,26 @@ #include #include #include - -#define PRINT_ERR_STREAM ctf_fs->error_fp -#define PRINT_PREFIX "ctf-fs-file" -#define PRINT_DBG_CHECK ctf_fs_debug -#include "../print.h" - #include "file.h" +#define BT_LOG_TAG "PLUGIN-CTF-FS-FILE-SRC" +#include "logging.h" + BT_HIDDEN void ctf_fs_file_destroy(struct ctf_fs_file *file) { - struct ctf_fs_component *ctf_fs;; - if (!file) { return; } - ctf_fs = file->ctf_fs; - if (file->fp) { - PDBG("Closing file \"%s\" (%p)\n", file->path->str, file->fp); + BT_LOGD("Closing file \"%s\" (%p)", + file->path ? file->path->str : NULL, file->fp); if (fclose(file->fp)) { - PERR("Cannot close file \"%s\": %s\n", file->path->str, - strerror(errno)); + BT_LOGE("Cannot close file \"%s\": %s", + file->path ? file->path->str : "NULL", + strerror(errno)); } } @@ -61,7 +56,7 @@ void ctf_fs_file_destroy(struct ctf_fs_file *file) } BT_HIDDEN -struct ctf_fs_file *ctf_fs_file_create(struct ctf_fs_component *ctf_fs) +struct ctf_fs_file *ctf_fs_file_create(void) { struct ctf_fs_file *file = g_new0(struct ctf_fs_file, 1); @@ -69,7 +64,6 @@ struct ctf_fs_file *ctf_fs_file_create(struct ctf_fs_component *ctf_fs) goto error; } - file->ctf_fs = ctf_fs; file->path = g_string_new(NULL); if (!file->path) { goto error; @@ -86,29 +80,28 @@ end: } BT_HIDDEN -int ctf_fs_file_open(struct ctf_fs_component *ctf_fs, struct ctf_fs_file *file, - const char *mode) +int ctf_fs_file_open(struct ctf_fs_file *file, const char *mode) { int ret = 0; struct stat stat; - PDBG("Opening file \"%s\" with mode \"%s\"\n", file->path->str, mode); + BT_LOGD("Opening file \"%s\" with mode \"%s\"", file->path->str, mode); file->fp = fopen(file->path->str, mode); if (!file->fp) { - PERR("Cannot open file \"%s\" with mode \"%s\": %s\n", + BT_LOGE("Cannot open file \"%s\" with mode \"%s\": %s", file->path->str, mode, strerror(errno)); goto error; } - PDBG("Opened file: %p\n", file->fp); + BT_LOGD("Opened file: %p", file->fp); if (fstat(fileno(file->fp), &stat)) { - PERR("Cannot get file informations: %s\n", strerror(errno)); + BT_LOGE("Cannot get file information: %s", strerror(errno)); goto error; } file->size = stat.st_size; - PDBG(" File is %zu bytes\n", file->size); + BT_LOGD("File is %jd bytes", (intmax_t) file->size); goto end; error: @@ -116,7 +109,7 @@ error: if (file->fp) { if (fclose(file->fp)) { - PERR("Cannot close file \"%s\": %s\n", file->path->str, + BT_LOGE("Cannot close file \"%s\": %s", file->path->str, strerror(errno)); } }