From 50e741126a0840179b86cf2302905e30dad6f75f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 19 Sep 2009 10:46:32 +0200 Subject: Add path string to the invalid_path exception --- cutl/fs/path.cxx | 2 +- cutl/fs/path.hxx | 35 +++++++++++++++++++++++++++++++---- cutl/fs/path.txx | 4 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) (limited to 'cutl') diff --git a/cutl/fs/path.cxx b/cutl/fs/path.cxx index 6e295c6..88b88f6 100644 --- a/cutl/fs/path.cxx +++ b/cutl/fs/path.cxx @@ -9,7 +9,7 @@ namespace cutl { namespace fs { - char const* invalid_path:: + char const* invalid_path_base:: what () const throw () { return "invalid filesystem path"; diff --git a/cutl/fs/path.hxx b/cutl/fs/path.hxx index f310d55..139a3cc 100644 --- a/cutl/fs/path.hxx +++ b/cutl/fs/path.hxx @@ -15,17 +15,44 @@ namespace cutl { namespace fs { - struct invalid_path: exception + template + class basic_path; + + template + class invalid_basic_path; + + typedef basic_path path; + typedef invalid_basic_path invalid_path; + + typedef basic_path wpath; + typedef invalid_basic_path invalid_wpath; + + // + // + struct invalid_path_base: exception { virtual char const* what () const throw (); }; template - class basic_path; + struct invalid_basic_path: invalid_path_base + { + typedef std::basic_string string_type; - typedef basic_path path; - typedef basic_path wpath; + invalid_basic_path (C const* p): path_ (p) {} + invalid_basic_path (string_type const& p): path_ (p) {} + ~invalid_basic_path () throw () {} + + string_type const& + path () const + { + return path_; + } + + private: + string_type path_; + }; template class basic_path diff --git a/cutl/fs/path.txx b/cutl/fs/path.txx index caff259..ff5095b 100644 --- a/cutl/fs/path.txx +++ b/cutl/fs/path.txx @@ -70,7 +70,7 @@ namespace cutl operator/ (basic_path const& r) { if (r.path_.empty ()) - throw invalid_path (); + throw invalid_basic_path (r.path_); basic_path x (*this); x.path_ += '/'; @@ -83,7 +83,7 @@ namespace cutl init (bool internal) { if (!internal && path_.empty ()) - throw invalid_path (); + throw invalid_basic_path (path_); // Strip trailing slashes. This way empty string represents // root directory. -- cgit v1.1