# # patch "ChangeLog" # from [6b1cb53cd93bd075671c9bed80791b7822f22426] # to [f22fc5208fad5ae7788c81b9c90654420b53df2e] # # patch "paths.cc" # from [bd2f39862eb4b9c2b5f96981db66c1b1c84d63d3] # to [0b241b1c009cc5577bf347e150b698f0eafbbb98] # # patch "paths.hh" # from [563467ed97bd1015a2e37fe54be6ca812c674598] # to [088b378c52d4687f4376c29a32c0174202f6b7f1] # ======================================================================== --- ChangeLog 6b1cb53cd93bd075671c9bed80791b7822f22426 +++ ChangeLog f22fc5208fad5ae7788c81b9c90654420b53df2e @@ -1,5 +1,13 @@ +2005-08-25 Nathaniel Smith + + * paths.cc (system_path): Implement. + 2005-08-24 Nathaniel Smith + * paths.cc (fully_normalized_path): Use find_first_of. + +2005-08-24 Nathaniel Smith + * paths.cc (find_and_go_to_working_copy, save_initial_path) (go_to_working_copy): Use new checked structure. (operator <<): Make sure we can log our access_tracked values ======================================================================== --- paths.cc bd2f39862eb4b9c2b5f96981db66c1b1c84d63d3 +++ paths.cc 0b241b1c009cc5577bf347e150b698f0eafbbb98 @@ -64,36 +64,11 @@ { // FIXME: BUG: this only works if the current working dir is in utf8 initial_abs_path.set(system_path(get_current_working_dir()), false); + // We still use boost::fs, so let's continue to initialize it properly. fs::initial_path(); L(F("initial abs path is: %s") % initial_abs_path); } -// path to prepend to external files, to convert them from pointing to the -// original working directory to the checkout's root. Always a normalized -// string with no trailing /. - -#ifdef _WIN32 -static const bool is_win32 = true; -#else -static const bool is_win32 = false; -#endif - -static bool -is_absolute(std::string const & path) -{ - if (path.empty()) - return false; - if (path[0] == '/') - return true; -#ifdef _WIN32 - if (path[0] == '\\') - return true; - if (path.size() > 1 && path[1] == ':') - return true; -#endif - return false; -} - /////////////////////////////////////////////////////////////////////////// // verifying that internal paths are indeed normalized. // this code must be superfast @@ -140,9 +115,8 @@ if (path.size() > 1 && path[1] == ':') return false; // first scan for completely illegal bytes - for (std::string::const_iterator i = path.begin(); i != path.end(); ++i) - if (bad_chars.find(*i) != std::string::npos) - return false; + if (path.find_first_of(bad_chars) != std::string::npos) + return false; // now check each component std::string::size_type start, stop; start = 0; @@ -324,6 +298,40 @@ } /////////////////////////////////////////////////////////////////////////// +// system_path +/////////////////////////////////////////////////////////////////////////// + +static bool +is_absolute(std::string const & path) +{ + if (path.empty()) + return false; + if (path[0] == '/') + return true; +#ifdef _WIN32 + if (path[0] == '\\') + return true; + if (path.size() > 1 && path[1] == ':') + return true; +#endif + return false; +} + +system_path::system_path(any_path const & other) +{ + I(!is_absolute(other.as_internal())); + data = (working_root.get() / other.as_internal()).as_internal(); +} + +system_path::system_path(std::string const & path) +{ + if (is_absolute(path)) + data = path; + else + data = (initial_abs_path.get() / other.as_internal()).as_internal(); +} + +/////////////////////////////////////////////////////////////////////////// // working copy (and path roots) handling /////////////////////////////////////////////////////////////////////////// ======================================================================== --- paths.hh 563467ed97bd1015a2e37fe54be6ca812c674598 +++ paths.hh 088b378c52d4687f4376c29a32c0174202f6b7f1 @@ -114,6 +114,7 @@ { public: system_path() {}; + system_path(system_path const & other) : any_path(other) {}; explicit system_path(any_path const & other); // this path can contain anything, and it will be absolutified and // tilde-expanded. it will considered to be relative to the directory