Skip to content

Commit ab5cf5f

Browse files
authored
Add support for logs directory (#55)
1 parent 92defae commit ab5cf5f

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub const KnownFolder = enum {
2525
local_configuration,
2626
global_configuration,
2727
data,
28+
logs,
2829
runtime,
2930
executable_dir,
3031
};

RESOURCES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
| Roaming Configuration | %APPDATA% | XDG_CONFIG_HOME | HOME/Library/Preferences |
3636
| Local Configuration | %LOCALAPPDATA% | XDG_CONFIG_HOME | HOME/Library/Application Support |
3737
| Data | %APPDATA% | XDG_DATA_HOME | HOME/Library/Application Support |
38+
| Logs | %LOCALAPPDATA%/Temp | XDG_STATE_HOME | HOME/Library/Logs |
3839
| Runtime | %LOCALAPPDATA%/Temp | XDG_RUNTIME_DIR | HOME/Library/Application Support |

known-folders.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ pub const KnownFolder = enum {
8989
///
9090
/// XDG's definition of `XDG_DATA_HOME`: There is a set of preference ordered base directories
9191
data,
92+
/// The base directory relative to which user-specific log files should be written.
93+
///
94+
/// Windows: `%LOCALAPPDATA%\Temp`
95+
/// MacOS default: `$HOME/Library/Logs`
96+
/// *nix default: `$HOME/.local/state`
97+
/// XDG directory: `XDG_STATE_HOME`
98+
logs,
9299
/// The base directory relative to which user-specific runtime files and other file objects should be placed.
93100
///
94101
/// Windows: `%LOCALAPPDATA%\Temp`
@@ -658,6 +665,7 @@ fn getWindowsFolderSpec(folder: KnownFolder) WindowsFolderSpec {
658665
.local_configuration => .{ .by_guid = comptime std.os.windows.GUID.parse("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}") }, // FOLDERID_LocalAppData
659666
.global_configuration => .{ .by_guid = comptime std.os.windows.GUID.parse("{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}") }, // FOLDERID_ProgramData
660667
.data => .{ .by_env = .{ .env_var = "APPDATA", .subdir = null } }, // %LOCALAPPDATA%\Temp
668+
.logs => .{ .by_env = .{ .env_var = "LOCALAPPDATA", .subdir = "Temp" } }, // %LOCALAPPDATA%\Temp
661669
.runtime => .{ .by_env = .{ .env_var = "LOCALAPPDATA", .subdir = "Temp" } },
662670
};
663671
}
@@ -681,6 +689,7 @@ fn getMacFolderSpec(folder: KnownFolder) []const u8 {
681689
.local_configuration => "Library/Application Support",
682690
.global_configuration => "/Library/Preferences", // absolute path
683691
.data => "Library/Application Support",
692+
.logs => "Library/Logs",
684693
.runtime => "Library/Application Support",
685694
};
686695
}
@@ -717,6 +726,7 @@ fn getXdgFolderSpec(folder: KnownFolder) XdgFolderSpec {
717726
.local_configuration => .{ .env = .{ .name = "XDG_CONFIG_HOME", .user_dir = false, .suffix = null }, .default = "~/.config" },
718727
.global_configuration => .{ .env = .{ .name = "XDG_CONFIG_DIRS", .user_dir = false, .suffix = null }, .default = "/etc" }, // absolute path
719728
.data => .{ .env = .{ .name = "XDG_DATA_HOME", .user_dir = false, .suffix = null }, .default = "~/.local/share" },
729+
.logs => .{ .env = .{ .name = "XDG_STATE_HOME", .user_dir = false, .suffix = null }, .default = "~/.local/state" },
720730
.runtime => .{ .env = .{ .name = "XDG_RUNTIME_DIR", .user_dir = false, .suffix = null }, .default = null },
721731
};
722732
}

0 commit comments

Comments
 (0)