feat: action map refactor, bugfix

This commit is contained in:
2025-06-22 06:31:52 +02:00
parent 4474933e54
commit 41e93e1f88
6 changed files with 125 additions and 26 deletions

View File

@@ -65,6 +65,22 @@ pub fn getFullNameByNativePath(allocator: std.mem.Allocator, nativePath: NativeP
}
pub fn getNativePathByFullName(allocator: std.mem.Allocator, fullName: FullName) ![]u8 {
std.debug.assert(!std.mem.endsWith(u8, fullName.path, "/"));
if (fullName.path.len < LocalProviderId.len or
!std.mem.eql(u8, fullName.path[0..LocalProviderId.len], LocalProviderId))
{
return ProviderError.WrongProvider;
}
//NOTE: their might be an other edge case where the fullname is local/ that is not handled by this
if (fullName.path.len == LocalProviderId.len) {
if (native_os == .linux)
return try std.fmt.allocPrint(allocator, "/", .{})
else
return ProviderError.WrongProvider;
}
const fullNameWithoutId = fullName.path[LocalProviderId.len + 1 ..];
var native_path = try std.mem.replaceOwned(u8, allocator, fullNameWithoutId, "/", std.fs.path.sep_str);
@@ -217,6 +233,7 @@ const models = @import("../models.zig");
const Provider = @import("provider.zig").Provider;
const ProviderVTable = @import("provider.zig").VTable;
const GetItemsError = @import("provider.zig").GetItemsError;
const ProviderError = @import("provider.zig").ProviderError;
const InitContext = @import("provider.zig").InitContext;
const FullName = models.FullName;