mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- `string::new_from_*` changed to `string::from_*`. - `String.to_utf16_copy` and related changed to `String.to_utf16`. - `String.to_utf16_tcopy` and related changed to `String.to_temp_utf16` - `mem::temp_new` changed to `mem::tnew`. - `mem::temp_alloc` and related changed to `mem::talloc`. - `mem::temp_new_array` changed to `mem::temp_array`.
31 lines
815 B
Plaintext
31 lines
815 B
Plaintext
module std::io::os;
|
|
import std::io::path, libc, std::os;
|
|
|
|
macro void! native_chdir(Path path)
|
|
{
|
|
$switch
|
|
$case env::POSIX:
|
|
if (posix::chdir(path.as_zstr()))
|
|
{
|
|
switch (libc::errno())
|
|
{
|
|
case errno::EACCES: return IoError.NO_PERMISSION?;
|
|
case errno::ENAMETOOLONG: return IoError.NAME_TOO_LONG?;
|
|
case errno::ENOTDIR: return IoError.FILE_NOT_DIR?;
|
|
case errno::ENOENT: return IoError.FILE_NOT_FOUND?;
|
|
case errno::ELOOP: return IoError.SYMLINK_FAILED?;
|
|
default: return IoError.GENERAL_ERROR?;
|
|
}
|
|
}
|
|
$case env::WIN32:
|
|
@pool()
|
|
{
|
|
// TODO improve with better error handling.
|
|
if (win32::setCurrentDirectoryW(path.str_view().to_temp_utf16()!!)) return;
|
|
};
|
|
return IoError.GENERAL_ERROR?;
|
|
$default:
|
|
return IoError.UNSUPPORTED_OPERATION?;
|
|
$endswitch
|
|
}
|