From 6f81c0103906376cf23a084f3a2b0807fbefc376 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Fri, 11 May 2007 14:49:50 -0700 Subject: [PATCH] Clean up error reporting. --- scandir.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scandir.cc b/scandir.cc index 2570be5..079324a 100644 --- a/scandir.cc +++ b/scandir.cc @@ -30,10 +30,10 @@ using std::ostream; static TarSegmentStore *tss = NULL; /* Buffer for holding a single block of data read from a file. */ -static const int LBS_BLOCK_SIZE = 1024 * 1024; +static const size_t LBS_BLOCK_SIZE = 1024 * 1024; static char *block_buf; -static const int LBS_METADATA_BLOCK_SIZE = 65536; +static const size_t LBS_METADATA_BLOCK_SIZE = 65536; /* Contents of the root object. This will contain a set of indirect links to * the metadata objects. */ @@ -106,7 +106,7 @@ void dumpfile(int fd, dictionary &file_info) list object_list; if ((stat_buf.st_mode & S_IFMT) != S_IFREG) { - printf("file is no longer a regular file!\n"); + fprintf(stderr, "file is no longer a regular file!\n"); return; } @@ -216,16 +216,14 @@ void scanfile(const string& path) buf = new char[stat_buf.st_size + 2]; len = readlink(path.c_str(), buf, stat_buf.st_size + 1); if (len < 0) { - printf("error reading symlink: %m\n"); + fprintf(stderr, "error reading symlink: %m\n"); } else if (len <= stat_buf.st_size) { buf[len] = '\0'; - printf(" contents=%s\n", buf); + file_info["contents"] = uri_encode(buf); } else if (len > stat_buf.st_size) { - printf("error reading symlink: name truncated\n"); + fprintf(stderr, "error reading symlink: name truncated\n"); } - file_info["contents"] = uri_encode(buf); - delete[] buf; break; case S_IFREG: @@ -284,7 +282,7 @@ void scandir(const string& path) DIR *dir = opendir(path.c_str()); if (dir == NULL) { - printf("Error: %m\n"); + fprintf(stderr, "Error: %m\n"); return; } -- 2.20.1