| ... | ... | @@ -789,21 +789,17 @@ pub const RealPathError = error{ |
| 789 | 789 | UnrecognizedVolume, |
| 790 | 790 | } || PathNameError || Io.Cancelable || Io.UnexpectedError; |
| 791 | 791 | |
| 792 | | /// This function returns the canonicalized absolute pathname of `pathname` |
| 793 | | /// relative to this `Dir`. If `pathname` is absolute, ignores this `Dir` |
| 794 | | /// handle and returns the canonicalized absolute pathname of `pathname` |
| 795 | | /// argument. |
| 792 | /// This function returns the canonicalized absolute path name of `sub_path` |
| 793 | /// relative to this `Dir`. If `sub_path` is absolute, ignores this `Dir` |
| 794 | /// handle and returns the canonicalized absolute pathname of `sub_path` |
| 795 | /// argument. |
| 796 | 796 | /// |
| 797 | | /// On Windows, `sub_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/). |
| 798 | | /// On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding. |
| 799 | | /// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/). |
| 800 | | /// On other platforms, the result is an opaque sequence of bytes with no particular encoding. |
| 801 | | /// |
| 802 | | /// This function is not universally supported by all platforms. Currently |
| 803 | | /// supported hosts are: Linux, macOS, and Windows. |
| 797 | /// This function is not universally supported by all platforms, and using this |
| 798 | /// function can lead to unnecessary failures and race conditions. |
| 804 | 799 | /// |
| 805 | 800 | /// See also: |
| 806 | 801 | /// * `realPathAlloc`. |
| 802 | /// * `realPathAbsolute`. |
| 807 | 803 | pub fn realPath(dir: Dir, io: Io, sub_path: []const u8, out_buffer: []u8) RealPathError!usize { |
| 808 | 804 | return io.vtable.dirRealPath(io.userdata, dir, sub_path, out_buffer); |
| 809 | 805 | } |
| ... | ... | @@ -811,18 +807,41 @@ pub fn realPath(dir: Dir, io: Io, sub_path: []const u8, out_buffer: []u8) RealPa |
| 811 | 807 | pub const RealPathAllocError = RealPathError || Allocator.Error; |
| 812 | 808 | |
| 813 | 809 | /// Same as `realPath` except allocates result. |
| 810 | /// |
| 811 | /// This function is not universally supported by all platforms, and using this |
| 812 | /// function can lead to unnecessary failures and race conditions. |
| 813 | /// |
| 814 | /// See also: |
| 815 | /// * `realPath`. |
| 816 | /// * `realPathAbsolute`. |
| 814 | 817 | pub fn realPathAlloc(dir: Dir, io: Io, sub_path: []const u8, allocator: Allocator) RealPathAllocError![:0]u8 { |
| 815 | 818 | var buffer: [max_path_bytes]u8 = undefined; |
| 816 | 819 | const n = try realPath(dir, io, sub_path, &buffer); |
| 817 | 820 | return allocator.dupeZ(u8, buffer[0..n]); |
| 818 | 821 | } |
| 819 | 822 | |
| 823 | /// Same as `realPath` except `absolute_path` is asserted to be an absolute |
| 824 | /// path. |
| 825 | /// |
| 826 | /// This function is not universally supported by all platforms, and using this |
| 827 | /// function can lead to unnecessary failures and race conditions. |
| 828 | /// |
| 829 | /// See also: |
| 830 | /// * `realPath`. |
| 831 | /// * `realPathAlloc`. |
| 820 | 832 | pub fn realPathAbsolute(io: Io, absolute_path: []const u8, out_buffer: []u8) RealPathError!usize { |
| 821 | 833 | assert(path.isAbsolute(absolute_path)); |
| 822 | 834 | return io.vtable.dirRealPath(io.userdata, .cwd(), absolute_path, out_buffer); |
| 823 | 835 | } |
| 824 | 836 | |
| 825 | 837 | /// Same as `realPathAbsolute` except allocates result. |
| 838 | /// |
| 839 | /// This function is not universally supported by all platforms, and using this |
| 840 | /// function can lead to unnecessary failures and race conditions. |
| 841 | /// |
| 842 | /// See also: |
| 843 | /// * `realPathAbsolute`. |
| 844 | /// * `realPath`. |
| 826 | 845 | pub fn realPathAbsoluteAlloc(io: Io, absolute_path: []const u8, allocator: Allocator) RealPathAllocError![:0]u8 { |
| 827 | 846 | var buffer: [max_path_bytes]u8 = undefined; |
| 828 | 847 | const n = try realPathAbsolute(io, absolute_path, &buffer); |