aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-10-24 13:18:23 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-10-24 13:18:23 +0300
commitbd42a54500e1a9e6113813f808c7726a7c24c1ad (patch)
tree82ec79fdb5c8290faaf2b7d7d9cf70d108a0d186
parent2fe7c710b13a0cd429b800fe5e147414c6c63596 (diff)
Add workaround for MSYS2-based sha256sum utility issue
-rw-r--r--bpkg/checksum.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/bpkg/checksum.cxx b/bpkg/checksum.cxx
index df7a546..f990ae5 100644
--- a/bpkg/checksum.cxx
+++ b/bpkg/checksum.cxx
@@ -7,6 +7,10 @@
#include <ios> // streamsize
#include <streambuf>
+#ifndef _WIN32
+# include <algorithm> // replace()
+#endif
+
#include <libbutl/sha256.mxx>
#include <libbutl/process.mxx>
#include <libbutl/fdstream.mxx>
@@ -142,7 +146,19 @@ namespace bpkg
for (const string& o: ops)
args.push_back (o.c_str ());
- args.push_back (file.string ().c_str ());
+ // By some reason, MSYS2-based sha256sum utility prints the redundant
+ // backslash character at the beginning of the sum. This somehow depends on
+ // the presence of backslashes in the file path, so we just get rid of
+ // them.
+ //
+#ifndef _WIN32
+ const string& f (file.string ());
+#else
+ string f (file.string ());
+ replace (f.begin (), f.end (), '\\', '/');
+#endif
+
+ args.push_back (f.c_str ());
args.push_back (nullptr);
process_path pp (process::path_search (args[0]));