| ... | ... | @@ -1800,8 +1800,13 @@ pub const SelfExePathError = os.ReadLinkError || os.SysCtlError; |
| 1800 | 1800 | /// `selfExePath` except allocates the result on the heap. |
| 1801 | 1801 | /// Caller owns returned memory. |
| 1802 | 1802 | pub fn selfExePathAlloc(allocator: *Allocator) ![]u8 { |
| 1803 | | // TODO(#4812): Consider looping with larger and larger buffers to handle |
| 1804 | | // overlong paths. |
| 1803 | // Use of MAX_PATH_BYTES here is justified as, at least on one tested Linux |
| 1804 | // system, readlink will completely fail to return a result larger than |
| 1805 | // PATH_MAX even if given a sufficiently large buffer. This makes it |
| 1806 | // fundamentally impossible to get the selfExePath of a program running in |
| 1807 | // a very deeply nested directory chain in this way. |
| 1808 | // TODO(#4812): Investigate other systems and whether it is possible to get |
| 1809 | // this path by trying larger and larger buffers until one succeeds. |
| 1805 | 1810 | var buf: [MAX_PATH_BYTES]u8 = undefined; |
| 1806 | 1811 | return mem.dupe(allocator, u8, try selfExePath(&buf)); |
| 1807 | 1812 | } |
| ... | ... | @@ -1858,8 +1863,13 @@ pub fn selfExePathW() [:0]const u16 { |
| 1858 | 1863 | /// `selfExeDirPath` except allocates the result on the heap. |
| 1859 | 1864 | /// Caller owns returned memory. |
| 1860 | 1865 | pub fn selfExeDirPathAlloc(allocator: *Allocator) ![]u8 { |
| 1861 | | // TODO(#4812): Consider looping with larger and larger buffers to handle |
| 1862 | | // overlong paths. |
| 1866 | // Use of MAX_PATH_BYTES here is justified as, at least on one tested Linux |
| 1867 | // system, readlink will completely fail to return a result larger than |
| 1868 | // PATH_MAX even if given a sufficiently large buffer. This makes it |
| 1869 | // fundamentally impossible to get the selfExeDirPath of a program running |
| 1870 | // in a very deeply nested directory chain in this way. |
| 1871 | // TODO(#4812): Investigate other systems and whether it is possible to get |
| 1872 | // this path by trying larger and larger buffers until one succeeds. |
| 1863 | 1873 | var buf: [MAX_PATH_BYTES]u8 = undefined; |
| 1864 | 1874 | return mem.dupe(allocator, u8, try selfExeDirPath(&buf)); |
| 1865 | 1875 | } |