Skip to content

Commit

Permalink
Allow asset file names to just end in .zon instead of .zig.zon
Browse files Browse the repository at this point in the history
.zig.zon should still be preferred due to having syntax highlighting on github.
  • Loading branch information
IntegratedQuantum committed Dec 16, 2024
1 parent be818cd commit 3f0f2f7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/assets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ pub fn readAllZonFilesInAddons(externalAllocator: NeverFailingAllocator, addons:
std.log.err("Got error while iterating addon directory {s}: {s}", .{subPath, @errorName(err)});
break :blk null;
}) |entry| {
if(entry.kind == .file and std.ascii.endsWithIgnoreCase(entry.basename, ".zig.zon") and !std.ascii.startsWithIgnoreCase(entry.path, "textures")) {
if(entry.kind == .file and std.ascii.endsWithIgnoreCase(entry.basename, ".zon") and !std.ascii.startsWithIgnoreCase(entry.path, "textures")) {
const fileSuffixLen = if(std.ascii.endsWithIgnoreCase(entry.basename, ".zig.zon")) ".zig.zon".len else ".zon".len;
const folderName = addonName;
const id: []u8 = externalAllocator.alloc(u8, folderName.len + 1 + entry.path.len - ".zig.zon".len);
const id: []u8 = externalAllocator.alloc(u8, folderName.len + 1 + entry.path.len - fileSuffixLen);
errdefer externalAllocator.free(id);
@memcpy(id[0..folderName.len], folderName);
id[folderName.len] = ':';
for(0..entry.path.len - ".zig.zon".len) |i| {
for(0..entry.path.len - fileSuffixLen) |i| {
if(entry.path[i] == '\\') { // Convert windows path seperators
id[folderName.len+1+i] = '/';
} else {
Expand Down

0 comments on commit 3f0f2f7

Please sign in to comment.