From 59db379f143f9accda21b831e0243d02f27c1c70 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 20 May 2008 12:01:42 +0000 Subject: [PATCH] Add chdir function --- source/utils.cpp | 6 ++++++ source/utils.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/source/utils.cpp b/source/utils.cpp index 18784b3..d9522a3 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -244,4 +244,10 @@ Path get_home_dir() #endif } +void chdir(const Path &path) +{ + if(::chdir(path.str().c_str())==-1) + throw SystemError("chdir failed", errno); +} + } // namespace Msp diff --git a/source/utils.h b/source/utils.h index db6a32c..b166fed 100644 --- a/source/utils.h +++ b/source/utils.h @@ -74,6 +74,9 @@ Path getcwd(); /// Returns the user's home directory Path get_home_dir(); +/// Changes the current working directory +void chdir(const Path &); + inline bool is_windows_drive(const std::string &p) { return (p.size()==2 && ((p[0]>='A' && p[0]<='Z') || (p[0]>='a' && p[0]<='z')) && p[1]==':'); } -- 2.43.0