| ... | ... | @@ -1825,26 +1825,20 @@ pub const Dir = struct { |
| 1825 | 1825 | } |
| 1826 | 1826 | }; |
| 1827 | 1827 | |
| 1828 | | pub fn changeCurDir(allocator: *Allocator, dir_path: []const u8) !void { |
| 1829 | | const path_buf = try allocator.alloc(u8, dir_path.len + 1); |
| 1830 | | defer allocator.free(path_buf); |
| 1831 | | |
| 1832 | | mem.copy(u8, path_buf, dir_path); |
| 1833 | | path_buf[dir_path.len] = 0; |
| 1834 | | |
| 1835 | | const err = posix.getErrno(posix.chdir(path_buf.ptr)); |
| 1836 | | if (err > 0) { |
| 1837 | | return switch (err) { |
| 1838 | | posix.EACCES => error.AccessDenied, |
| 1839 | | posix.EFAULT => unreachable, |
| 1840 | | posix.EIO => error.FileSystem, |
| 1841 | | posix.ELOOP => error.SymLinkLoop, |
| 1842 | | posix.ENAMETOOLONG => error.NameTooLong, |
| 1843 | | posix.ENOENT => error.FileNotFound, |
| 1844 | | posix.ENOMEM => error.SystemResources, |
| 1845 | | posix.ENOTDIR => error.NotDir, |
| 1846 | | else => unexpectedErrorPosix(err), |
| 1847 | | }; |
| 1828 | pub fn changeCurDir(dir_path: []const u8) !void { |
| 1829 | const dir_path_c = try toPosixPath(dir_path); |
| 1830 | const err = posix.getErrno(posix.chdir(&dir_path_c)); |
| 1831 | switch (err) { |
| 1832 | 0 => return, |
| 1833 | posix.EACCES => return error.AccessDenied, |
| 1834 | posix.EFAULT => unreachable, |
| 1835 | posix.EIO => return error.FileSystem, |
| 1836 | posix.ELOOP => return error.SymLinkLoop, |
| 1837 | posix.ENAMETOOLONG => return error.NameTooLong, |
| 1838 | posix.ENOENT => return error.FileNotFound, |
| 1839 | posix.ENOMEM => return error.SystemResources, |
| 1840 | posix.ENOTDIR => return error.NotDir, |
| 1841 | else => return unexpectedErrorPosix(err), |
| 1848 | 1842 | } |
| 1849 | 1843 | } |
| 1850 | 1844 | |