// file : cutl/fs/path.cxx // author : Boris Kolpackov // copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file #ifdef _WIN32 # include // _getcwd, _wgetcwd, _MAX_PATH #else # include // mbstowcs # include // PATH_MAX # include // getcwd #endif #include namespace cutl { namespace fs { char const* invalid_path_base:: what () const throw () { return "invalid filesystem path"; } template <> basic_path basic_path:: current () { #ifdef _WIN32 char cwd[_MAX_PATH]; if(_getcwd(cwd, _MAX_PATH) == 0) throw invalid_basic_path ("."); #else char cwd[PATH_MAX]; if (getcwd (cwd, PATH_MAX) == 0) throw invalid_basic_path ("."); #endif return basic_path (cwd); } template <> basic_path basic_path:: current () { #ifdef _WIN32 wchar_t wcwd[_MAX_PATH]; if(_wgetcwd(wcwd, _MAX_PATH) == 0) throw invalid_basic_path ("."); #else char cwd[PATH_MAX]; if (getcwd (cwd, PATH_MAX) == 0) throw invalid_basic_path (L"."); wchar_t wcwd[PATH_MAX]; if (mbstowcs (wcwd, cwd, PATH_MAX) == size_type (-1)) throw invalid_basic_path (L"."); #endif return basic_path (wcwd); } } }