mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-09 15:19:13 +02:00
Migrate from known deprecated code
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
33eff94456
commit
4cbd8a9b35
6 changed files with 34 additions and 30 deletions
34
build.zig
34
build.zig
|
|
@ -135,25 +135,25 @@ pub fn Installer(install_config: bool) type {
|
|||
}
|
||||
|
||||
fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, install_config: bool) !void {
|
||||
const ly_config_directory = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly" });
|
||||
const ly_config_directory = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly" });
|
||||
|
||||
std.Io.Dir.cwd().createDirPath(io, ly_config_directory) catch {
|
||||
std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory});
|
||||
};
|
||||
|
||||
const ly_custom_sessions_directory = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/custom-sessions" });
|
||||
const ly_custom_sessions_directory = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/custom-sessions" });
|
||||
|
||||
std.Io.Dir.cwd().createDirPath(io, ly_custom_sessions_directory) catch {
|
||||
std.debug.print("warn: {s} already exists as a directory.\n", .{ly_custom_sessions_directory});
|
||||
};
|
||||
|
||||
const ly_lang_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/lang" });
|
||||
const ly_lang_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/lang" });
|
||||
std.Io.Dir.cwd().createDirPath(io, ly_lang_path) catch {
|
||||
std.debug.print("warn: {s} already exists as a directory.\n", .{ly_lang_path});
|
||||
};
|
||||
|
||||
{
|
||||
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
|
||||
const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
|
||||
std.Io.Dir.cwd().createDirPath(io, exe_path) catch {
|
||||
if (!std.mem.eql(u8, dest_directory, "")) {
|
||||
std.debug.print("warn: {s} already exists as a directory.\n", .{exe_path});
|
||||
|
|
@ -227,7 +227,7 @@ fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, ins
|
|||
}
|
||||
|
||||
{
|
||||
const pam_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/pam.d" });
|
||||
const pam_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/pam.d" });
|
||||
std.Io.Dir.cwd().createDirPath(io, pam_path) catch {
|
||||
if (!std.mem.eql(u8, dest_directory, "")) {
|
||||
std.debug.print("warn: {s} already exists as a directory.\n", .{pam_path});
|
||||
|
|
@ -245,7 +245,7 @@ fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, ins
|
|||
fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap) !void {
|
||||
switch (init_system) {
|
||||
.systemd => {
|
||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/lib/systemd/system" });
|
||||
const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/lib/systemd/system" });
|
||||
std.Io.Dir.cwd().createDirPath(io, service_path) catch {};
|
||||
var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable;
|
||||
defer service_dir.close(io);
|
||||
|
|
@ -257,7 +257,7 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
try installText(io, patched_kmsconvt_service, service_dir, service_path, "ly-kmsconvt@.service", .{ .permissions = .fromMode(0o644) });
|
||||
},
|
||||
.openrc => {
|
||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" });
|
||||
const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" });
|
||||
std.Io.Dir.cwd().createDirPath(io, service_path) catch {};
|
||||
var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable;
|
||||
defer service_dir.close(io);
|
||||
|
|
@ -266,12 +266,12 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
try installText(io, patched_service, service_dir, service_path, executable_name, .{ .permissions = .fromMode(0o755) });
|
||||
},
|
||||
.runit => {
|
||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/sv/ly" });
|
||||
const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/sv/ly" });
|
||||
std.Io.Dir.cwd().createDirPath(io, service_path) catch {};
|
||||
var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable;
|
||||
defer service_dir.close(io);
|
||||
|
||||
const supervise_path = try std.fs.path.join(allocator, &[_][]const u8{ service_path, "supervise" });
|
||||
const supervise_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ service_path, "supervise" });
|
||||
|
||||
const patched_conf = try patchFile(allocator, io, "res/ly-runit-service/conf", patch_map);
|
||||
try installText(io, patched_conf, service_dir, service_path, "conf", .{});
|
||||
|
|
@ -291,7 +291,7 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
std.debug.print("info: installed symlink /run/runit/supervise.ly\n", .{});
|
||||
},
|
||||
.s6 => {
|
||||
const admin_service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/adminsv/default/contents.d" });
|
||||
const admin_service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/adminsv/default/contents.d" });
|
||||
std.Io.Dir.cwd().createDirPath(io, admin_service_path) catch {};
|
||||
var admin_service_dir = std.Io.Dir.cwd().openDir(io, admin_service_path, .{}) catch unreachable;
|
||||
defer admin_service_dir.close(io);
|
||||
|
|
@ -299,7 +299,7 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
const file = try admin_service_dir.createFile(io, "ly-srv", .{});
|
||||
file.close(io);
|
||||
|
||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/sv/ly-srv" });
|
||||
const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/sv/ly-srv" });
|
||||
std.Io.Dir.cwd().createDirPath(io, service_path) catch {};
|
||||
var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable;
|
||||
defer service_dir.close(io);
|
||||
|
|
@ -310,7 +310,7 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
try installFile(io, "res/ly-s6/type", service_dir, service_path, "type", .{});
|
||||
},
|
||||
.dinit => {
|
||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/dinit.d" });
|
||||
const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/dinit.d" });
|
||||
std.Io.Dir.cwd().createDirPath(io, service_path) catch {};
|
||||
var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable;
|
||||
defer service_dir.close(io);
|
||||
|
|
@ -319,7 +319,7 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
try installText(io, patched_service, service_dir, service_path, "ly", .{});
|
||||
},
|
||||
.sysvinit => {
|
||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" });
|
||||
const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" });
|
||||
std.Io.Dir.cwd().createDirPath(io, service_path) catch {};
|
||||
var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable;
|
||||
defer service_dir.close(io);
|
||||
|
|
@ -328,7 +328,7 @@ fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap
|
|||
try installText(io, patched_service, service_dir, service_path, "ly", .{ .permissions = .fromMode(0o755) });
|
||||
},
|
||||
.freebsd => {
|
||||
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
|
||||
const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
|
||||
var executable_dir = std.Io.Dir.cwd().openDir(io, exe_path, .{}) catch unreachable;
|
||||
defer executable_dir.close(io);
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ pub fn Uninstaller(uninstall_config: bool) type {
|
|||
try deleteTree(allocator, io, config_directory, "/ly", "ly config directory not found");
|
||||
}
|
||||
|
||||
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ prefix_directory, "/bin/", executable_name });
|
||||
const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ prefix_directory, "/bin/", executable_name });
|
||||
var success = true;
|
||||
std.Io.Dir.cwd().deleteFile(io, exe_path) catch {
|
||||
std.debug.print("warn: ly executable not found\n", .{});
|
||||
|
|
@ -488,7 +488,7 @@ fn deleteFile(
|
|||
file: []const u8,
|
||||
warning: []const u8,
|
||||
) !void {
|
||||
const path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix, file });
|
||||
const path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix, file });
|
||||
|
||||
std.Io.Dir.cwd().deleteFile(io, path) catch |err| {
|
||||
if (err == error.FileNotFound) {
|
||||
|
|
@ -509,7 +509,7 @@ fn deleteTree(
|
|||
directory: []const u8,
|
||||
warning: []const u8,
|
||||
) !void {
|
||||
const path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix, directory });
|
||||
const path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix, directory });
|
||||
|
||||
var dir = std.Io.Dir.cwd().openDir(io, path, .{}) catch |err| {
|
||||
if (err == error.FileNotFound) {
|
||||
|
|
|
|||
|
|
@ -12,5 +12,9 @@
|
|||
.hash = "clap-0.11.0-oBajB7foAQC3Iyn4IVCkUdYaOVVng5IZkSncySTjNig1",
|
||||
},
|
||||
},
|
||||
.paths = .{""},
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ fn draw(self: *ColorMix) void {
|
|||
uv -= @splat(1.0 * math.cos(uv[0] + uv[1]) - math.sin(uv[0] * 0.7 - uv[1]));
|
||||
}
|
||||
|
||||
const cell = self.palette[@as(usize, @intFromFloat(math.floor(length(uv) * 5.0))) % palette_len];
|
||||
const cell = self.palette[@as(usize, @trunc(math.floor(length(uv) * 5.0))) % palette_len];
|
||||
cell.put(x, y);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ pub fn init(
|
|||
const frame_size = calc_frame_size(terminal_buffer, &dur_movie);
|
||||
|
||||
// Convert dur fps to frames per ms
|
||||
const frame_time: u32 = @intFromFloat(1000 / dur_movie.framerate.?);
|
||||
const frame_time: u32 = @trunc(1000 / dur_movie.framerate.?);
|
||||
|
||||
return .{
|
||||
.instance = null,
|
||||
|
|
@ -506,7 +506,7 @@ fn draw(self: *DurFile) void {
|
|||
const delta_time = time_current - self.time_previous;
|
||||
|
||||
// Convert delay from sec to ms
|
||||
const delay_time: u32 = @intFromFloat(current_frame.delay * 1000);
|
||||
const delay_time: u32 = @trunc(current_frame.delay * 1000);
|
||||
if (delta_time > (self.frame_time + delay_time)) {
|
||||
self.time_previous = time_current;
|
||||
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ fn executeCmd(global_log_file: *LogFile, allocator: std.mem.Allocator, io: std.I
|
|||
|
||||
fn redirectStandardStreams(global_log_file: *LogFile, io: std.Io, session_log: []const u8, create: bool) !std.Io.File {
|
||||
create_session_log_dir: {
|
||||
const session_log_dir = std.fs.path.dirname(session_log) orelse break :create_session_log_dir;
|
||||
const session_log_dir = std.Io.Dir.path.dirname(session_log) orelse break :create_session_log_dir;
|
||||
std.Io.Dir.cwd().createDirPath(io, session_log_dir) catch |err| {
|
||||
try global_log_file.err(io, "auth/sys", "failed to create session log file directory: {s}", .{@errorName(err)});
|
||||
return err;
|
||||
|
|
@ -576,7 +576,7 @@ fn addUtmpEntry(io: std.Io, entry: *Utmp, username: []const u8, pid: c_int) !voi
|
|||
entry.ut_type = utmp.USER_PROCESS;
|
||||
entry.ut_pid = pid;
|
||||
|
||||
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||
var buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
|
||||
const length = try std.Io.File.stdin().realPath(io, &buf);
|
||||
const tty_path = buf[0..length];
|
||||
|
||||
|
|
|
|||
14
src/main.zig
14
src/main.zig
|
|
@ -223,7 +223,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
state.allocator.free(state.old_save_path);
|
||||
};
|
||||
|
||||
const config_path = try std.fs.path.join(state.allocator, &[_][]const u8{ config_parent_path, "config.ini" });
|
||||
const config_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "config.ini" });
|
||||
defer state.allocator.free(config_path);
|
||||
|
||||
custom.binds = .empty;
|
||||
|
|
@ -252,7 +252,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
var lang_buffer: [16]u8 = undefined;
|
||||
const lang_file = try std.fmt.bufPrint(&lang_buffer, "{s}.ini", .{state.config.lang});
|
||||
|
||||
const lang_path = try std.fs.path.join(state.allocator, &[_][]const u8{ config_parent_path, "lang", lang_file });
|
||||
const lang_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "lang", lang_file });
|
||||
defer state.allocator.free(lang_path);
|
||||
|
||||
var lang_parser = try IniParser(Lang).init(state.allocator, state.io, lang_path, null);
|
||||
|
|
@ -261,8 +261,8 @@ pub fn main(init: std.process.Init) !void {
|
|||
state.lang = lang_parser.structure;
|
||||
|
||||
if (state.config.save) {
|
||||
state.save_path = try std.fs.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.txt" });
|
||||
state.old_save_path = try std.fs.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.ini" });
|
||||
state.save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.txt" });
|
||||
state.old_save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.ini" });
|
||||
save_path_alloc = true;
|
||||
}
|
||||
|
||||
|
|
@ -2117,14 +2117,14 @@ fn addOtherEnvironment(session: *Session, lang: Lang, display_server: DisplaySer
|
|||
}
|
||||
|
||||
fn crawl(session: *Session, io: std.Io, lang: Lang, path: []const u8, display_server: DisplayServer) !void {
|
||||
if (!std.fs.path.isAbsolute(path)) return error.PathNotAbsolute;
|
||||
if (!std.Io.Dir.path.isAbsolute(path)) return error.PathNotAbsolute;
|
||||
|
||||
var iterable_directory = try std.Io.Dir.openDirAbsolute(io, path, .{ .iterate = true });
|
||||
defer iterable_directory.close(io);
|
||||
|
||||
var iterator = iterable_directory.iterate();
|
||||
while (try iterator.next(io)) |item| {
|
||||
if (!std.mem.eql(u8, std.fs.path.extension(item.name), ".desktop")) continue;
|
||||
if (!std.mem.eql(u8, std.Io.Dir.path.extension(item.name), ".desktop")) continue;
|
||||
|
||||
const entry_path = try std.fmt.allocPrint(session.label.allocator, "{s}/{s}", .{ path, item.name });
|
||||
defer session.label.allocator.free(entry_path);
|
||||
|
|
@ -2135,7 +2135,7 @@ fn crawl(session: *Session, io: std.Io, lang: Lang, path: []const u8, display_se
|
|||
});
|
||||
errdefer entry_ini.deinit();
|
||||
|
||||
const file_name = try session.label.allocator.dupe(u8, std.fs.path.stem(item.name));
|
||||
const file_name = try session.label.allocator.dupe(u8, std.Io.Dir.path.stem(item.name));
|
||||
const entry = data.@"Desktop Entry";
|
||||
var maybe_xdg_session_desktop: ?[]const u8 = null;
|
||||
var maybe_xdg_desktop_names: ?[]const u8 = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue