From 0c2f5c67b8a8d88925df2e40908ff519115232c8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 29 Apr 2015 04:33:00 +0000 Subject: [PATCH] fix file_filter bug in make_torrent.cpp --- examples/make_torrent.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/make_torrent.cpp b/examples/make_torrent.cpp index e8d7c629a..5af2aae8b 100644 --- a/examples/make_torrent.cpp +++ b/examples/make_torrent.cpp @@ -143,11 +143,16 @@ bool file_filter(std::string const& f) char const* sep = strrchr(first, '/'); #if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2) char const* altsep = strrchr(first, '\\'); - if (sep == 0 || altsep > sep) sep = altsep; + if (sep == NULL || altsep > sep) sep = altsep; #endif + // if there is no parent path, just set 'sep' + // to point to the filename. + // if there is a parent path, skip the '/' character + if (sep == NULL) sep = first; + else ++sep; + // return false if the first character of the filename is a . - if (sep == 0 && f[0] == '.') return false; - if (sep[1] == '.') return false; + if (sep[0] == '.') return false; fprintf(stderr, "%s\n", f.c_str()); return true;