summaryrefslogtreecommitdiff
path: root/src/global.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/global.zig')
-rw-r--r--src/global.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/global.zig b/src/global.zig
index 375c10538..668d2faec 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -9,6 +9,7 @@ const harfbuzz = @import("harfbuzz");
const oni = @import("oniguruma");
const crash = @import("crash/main.zig");
const renderer = @import("renderer.zig");
+const apprt = @import("apprt.zig");
/// We export the xev backend we want to use so that the rest of
/// Ghostty can import this once and have access to the proper
@@ -35,7 +36,7 @@ pub const GlobalState = struct {
/// The app resources directory, equivalent to zig-out/share when we build
/// from source. This is null if we can't detect it.
- resources_dir: ?[]const u8,
+ resources_dir: internal_os.ResourcesDir,
/// Where logging should go
pub const Logging = union(enum) {
@@ -62,7 +63,7 @@ pub const GlobalState = struct {
.action = null,
.logging = .{ .stderr = {} },
.rlimits = .{},
- .resources_dir = null,
+ .resources_dir = .{},
};
errdefer self.deinit();
@@ -139,7 +140,7 @@ pub const GlobalState = struct {
std.log.info("libxev default backend={s}", .{@tagName(xev.backend)});
// As early as possible, initialize our resource limits.
- self.rlimits = ResourceLimits.init();
+ self.rlimits = .init();
// Initialize our crash reporting.
crash.init(self.alloc) catch |err| {
@@ -170,11 +171,11 @@ pub const GlobalState = struct {
// Find our resources directory once for the app so every launch
// hereafter can use this cached value.
- self.resources_dir = try internal_os.resourcesDir(self.alloc);
- errdefer if (self.resources_dir) |dir| self.alloc.free(dir);
+ self.resources_dir = try apprt.runtime.resourcesDir(self.alloc);
+ errdefer self.resources_dir.deinit(self.alloc);
// Setup i18n
- if (self.resources_dir) |v| internal_os.i18n.init(v) catch |err| {
+ if (self.resources_dir.app()) |v| internal_os.i18n.init(v) catch |err| {
std.log.warn("failed to init i18n, translations will not be available err={}", .{err});
};
}
@@ -182,7 +183,7 @@ pub const GlobalState = struct {
/// Cleans up the global state. This doesn't _need_ to be called but
/// doing so in dev modes will check for memory leaks.
pub fn deinit(self: *GlobalState) void {
- if (self.resources_dir) |dir| self.alloc.free(dir);
+ self.resources_dir.deinit(self.alloc);
// Flush our crash logs
crash.deinit();