From 6c8623320f0f03726dbbe84570e2f7a1f4cd9df0 Mon Sep 17 00:00:00 2001 From: R-Goc Date: Fri, 30 May 2025 10:44:19 +0200 Subject: [PATCH] LibCore: Implement chdir on Windows This commit adds a wrapper around chdir in LibCore. Co-authored-by: Andrew Kaster --- Libraries/LibCore/SystemWindows.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Libraries/LibCore/SystemWindows.cpp b/Libraries/LibCore/SystemWindows.cpp index a791a5f2138..991f1d31743 100644 --- a/Libraries/LibCore/SystemWindows.cpp +++ b/Libraries/LibCore/SystemWindows.cpp @@ -126,6 +126,17 @@ ErrorOr getcwd() return string_cwd; } +ErrorOr chdir(StringView path) +{ + if (path.is_null()) + return Error::from_errno(EFAULT); + + ByteString path_string = path; + if (::_chdir(path_string.characters()) < 0) + return Error::from_syscall("chdir"sv, errno); + return {}; +} + ErrorOr stat(StringView path) { if (path.is_null())