mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
std.fs: Add MAX_NAME_BYTES
Also add some NAME_MAX or equivalent definitions where necessary
This commit is contained in:
parent
e036cc48d5
commit
33fdc43714
@ -1014,6 +1014,7 @@ pub const vm_machine_attribute_val_t = isize;
|
||||
pub const CALENDAR_CLOCK = 1;
|
||||
|
||||
pub const PATH_MAX = 1024;
|
||||
pub const NAME_MAX = 255;
|
||||
pub const IOV_MAX = 16;
|
||||
|
||||
pub const STDIN_FILENO = 0;
|
||||
|
||||
@ -234,6 +234,7 @@ pub const SA = struct {
|
||||
};
|
||||
|
||||
pub const PATH_MAX = 1024;
|
||||
pub const NAME_MAX = 255;
|
||||
pub const IOV_MAX = KERN.IOV_MAX;
|
||||
|
||||
pub const ino_t = c_ulong;
|
||||
|
||||
@ -266,6 +266,7 @@ pub const area_info = extern struct {
|
||||
};
|
||||
|
||||
pub const MAXPATHLEN = PATH_MAX;
|
||||
pub const MAXNAMLEN = NAME_MAX;
|
||||
|
||||
pub const image_info = extern struct {
|
||||
id: u32,
|
||||
@ -371,6 +372,7 @@ pub const KERN = struct {};
|
||||
pub const IOV_MAX = 1024;
|
||||
|
||||
pub const PATH_MAX = 1024;
|
||||
pub const NAME_MAX = 256;
|
||||
|
||||
pub const STDIN_FILENO = 0;
|
||||
pub const STDOUT_FILENO = 1;
|
||||
|
||||
@ -48,6 +48,23 @@ pub const MAX_PATH_BYTES = switch (builtin.os.tag) {
|
||||
@compileError("PATH_MAX not implemented for " ++ @tagName(builtin.os.tag)),
|
||||
};
|
||||
|
||||
/// This represents the maximum size of a UTF-8 encoded file name component that the
|
||||
/// operating system will accept. All file name components returned by file system
|
||||
/// operations are assumed to fit into a UTF-8 encoded array of this length.
|
||||
/// The byte count does not include a null sentinel byte.
|
||||
pub const MAX_NAME_BYTES = switch (builtin.os.tag) {
|
||||
.linux, .macos, .ios, .freebsd, .dragonfly, .haiku => os.NAME_MAX,
|
||||
.netbsd, .openbsd, .solaris => os.MAXNAMLEN,
|
||||
// Each UTF-16LE character may be expanded to 3 UTF-8 bytes.
|
||||
// If it would require 4 UTF-8 bytes, then there would be a surrogate
|
||||
// pair in the UTF-16LE, and we (over)account 3 bytes for it that way.
|
||||
.windows => os.NAME_MAX * 3,
|
||||
else => if (@hasDecl(root, "os") and @hasDecl(root.os, "NAME_MAX"))
|
||||
root.os.NAME_MAX
|
||||
else
|
||||
@compileError("NAME_MAX not implemented for " ++ @tagName(builtin.os.tag)),
|
||||
};
|
||||
|
||||
pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;
|
||||
|
||||
/// Base64 encoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.
|
||||
|
||||
@ -2977,6 +2977,12 @@ pub const PMEMORY_BASIC_INFORMATION = *MEMORY_BASIC_INFORMATION;
|
||||
/// from https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation
|
||||
pub const PATH_MAX_WIDE = 32767;
|
||||
|
||||
/// > [Each file name component can be] up to the value returned in the
|
||||
/// > lpMaximumComponentLength parameter of the GetVolumeInformation function
|
||||
/// > (this value is commonly 255 characters)
|
||||
/// from https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
|
||||
pub const NAME_MAX = 255;
|
||||
|
||||
pub const FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
|
||||
pub const FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
|
||||
pub const FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user