From ef8d8c01a4d630b55ee4cf7a23688a5a5d685419 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 29 Sep 2021 11:16:22 +0200 Subject: Factor path::{sub,sup}() to path_traits::{sub,sup}() --- libbutl/path.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libbutl/path.hxx') diff --git a/libbutl/path.hxx b/libbutl/path.hxx index 8276130..fae145e 100644 --- a/libbutl/path.hxx +++ b/libbutl/path.hxx @@ -373,6 +373,22 @@ namespace butl : (p = rfind_separator (s, n - 1)) == nullptr ? s : ++p; } + // Return true if sb is a sub-path of sp (i.e., sp is a prefix). Expects + // both paths to be normalized. Note that this function returns true if + // the paths are equal. Empty path is considered a prefix of any path. + // + static bool + sub (const C* sb, size_type nb, + const C* sp, size_type np); + + // Return true if sp is a super-path of sb (i.e., sb is a suffix). Expects + // both paths to be normalized. Note that this function returns true if + // the paths are equal. Empty path is considered a prefix of any path. + // + static bool + sup (const C* sp, size_type np, + const C* sb, size_type nb); + static int compare (string_type const& l, string_type const& r, -- cgit v1.1