mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 23:38:57 +00:00
Add getAppDir implementation for iOS
This commit is contained in:
committed by
Pierre Tachoire
parent
901294a180
commit
3b5c7b0c25
BIN
src/.DS_Store
vendored
Normal file
BIN
src/.DS_Store
vendored
Normal file
Binary file not shown.
18
src/app.zig
18
src/app.zig
@@ -94,16 +94,24 @@ pub const App = struct {
|
||||
}
|
||||
};
|
||||
|
||||
fn getAppDir(allocator: Allocator) ![]const u8 {
|
||||
if (@import("builtin").os.tag == .ios) {
|
||||
// std.fs.getAppDataDir is not available on iOS, so we inline the same macOS implementation here.
|
||||
const home_dir = std.posix.getenv("HOME") orelse {
|
||||
return error.AppDataDirUnavailable;
|
||||
};
|
||||
return std.fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", "lightpanda" });
|
||||
} else {
|
||||
return try std.fs.getAppDataDir(allocator, "lightpanda");
|
||||
}
|
||||
}
|
||||
|
||||
fn getAndMakeAppDir(allocator: Allocator) ?[]const u8 {
|
||||
if (@import("builtin").is_test) {
|
||||
return allocator.dupe(u8, "/tmp") catch unreachable;
|
||||
}
|
||||
|
||||
if (@import("builtin").os.tag == .ios) {
|
||||
return null; // getAppDataDir is not available on iOS
|
||||
}
|
||||
|
||||
const app_dir_path = std.fs.getAppDataDir(allocator, "lightpanda") catch |err| {
|
||||
const app_dir_path = getAppDir(allocator) catch |err| {
|
||||
log.warn(.app, "get data dir", .{ .err = err });
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user