| Line | |
|---|
| 1 | /* |
|---|
| 2 | * |
|---|
| 3 | * Copyright (c) 2003 Dr John Maddock |
|---|
| 4 | * Use, modification and distribution is subject to the |
|---|
| 5 | * Boost Software License, Version 1.0. (See accompanying file |
|---|
| 6 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 7 | * |
|---|
| 8 | * This file implements path comparisons |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | #include "bcp_imp.hpp" |
|---|
| 13 | #include <cctype> |
|---|
| 14 | |
|---|
| 15 | #ifdef BOOST_NO_STDC_NAMESPACE |
|---|
| 16 | namespace std{ |
|---|
| 17 | using ::tolower; |
|---|
| 18 | } |
|---|
| 19 | #endif |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | int compare_paths(const fs::path& a, const fs::path& b) |
|---|
| 23 | { |
|---|
| 24 | const std::string& as = a.string(); |
|---|
| 25 | const std::string& bs = b.string(); |
|---|
| 26 | std::string::const_iterator i, j, k, l; |
|---|
| 27 | i = as.begin(); |
|---|
| 28 | j = as.end(); |
|---|
| 29 | k = bs.begin(); |
|---|
| 30 | l = bs.end(); |
|---|
| 31 | while(i != j) |
|---|
| 32 | { |
|---|
| 33 | if(k == l) |
|---|
| 34 | return -1; |
|---|
| 35 | int r = std::tolower(*i) - std::tolower(*k); |
|---|
| 36 | if(r) return r; |
|---|
| 37 | ++i; |
|---|
| 38 | ++k; |
|---|
| 39 | } |
|---|
| 40 | return (k == l) ? 0 : 1; |
|---|
| 41 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.