From b94b5381f68061121c22f2786ba1fa774f1ee6f6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 30 Jul 2016 17:25:23 +0200 Subject: Convert to use canonical directory separators --- bpkg/auth.cxx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'bpkg/auth.cxx') diff --git a/bpkg/auth.cxx b/bpkg/auth.cxx index a9eaa76..2c5d3d8 100644 --- a/bpkg/auth.cxx +++ b/bpkg/auth.cxx @@ -37,16 +37,18 @@ namespace bpkg // Construct the prefix as a relative repository location. // - string p ("."); + dir_path p; for (auto i (rl.path ().rbegin ()), e (rl.path ().rend ()); i != e; ++i) { const string& c (*i); if (!c.empty () && c.find_first_not_of ("1234567890") == string::npos) break; - p = "../" + p; + p /= ".."; } + p /= "."; + // If this is a remote location then use the canonical name prefix. For // a local location this doesn't always work. Consider: // @@ -57,13 +59,9 @@ namespace bpkg // use the location rather than the name prefix. // if (rl.remote ()) - return repository_location (p, rl).canonical_name (); + return repository_location (p.posix_string (), rl).canonical_name (); else - { - path lp (rl.path () / path (p)); - lp.normalize (); - return lp.string (); - } + return (rl.path () / p).normalize ().string (); } // Authenticate a dummy certificate. If trusted, it will authenticate all @@ -512,8 +510,6 @@ namespace bpkg return cert; } - static const dir_path certs_dir (".bpkg/certs"); - // Authenticate a certificate with the database. First check if it is // already authenticated. If not, authenticate and add to the database. // @@ -579,7 +575,7 @@ namespace bpkg fail << "--trust-yes and --trust-no are mutually exclusive"; if (conf != nullptr && conf->empty ()) - conf = dir_exists (path (".bpkg")) ? ¤t_dir : nullptr; + conf = dir_exists (bpkg_dir) ? ¤t_dir : nullptr; assert (conf == nullptr || !conf->empty ()); @@ -619,7 +615,7 @@ namespace bpkg tracer trace ("authenticate_repository"); if (conf != nullptr && conf->empty ()) - conf = dir_exists (path (".bpkg")) ? ¤t_dir : nullptr; + conf = dir_exists (bpkg_dir) ? ¤t_dir : nullptr; assert (conf == nullptr || !conf->empty ()); -- cgit v1.1