finished?

This commit is contained in:
2026-05-21 19:50:29 +02:00
parent d02489507d
commit ea225b9c33
7 changed files with 7 additions and 5 deletions
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File
View File
Binary file not shown.
-2
View File
@@ -33,12 +33,10 @@ pub fn classify(name: []const u8) Category {
for (entry.extensions) |ext| {
const eicDocument = std.ascii.eqlIgnoreCase(extension, ext);
if (eicDocument) {
std.debug.print("{s} found!\n", .{@tagName(entry.category)});
return entry.category;
}
}
}
std.debug.print("no compatible extensions found! \n", .{});
return .other;
}
+1 -1
View File
@@ -7,7 +7,7 @@ pub fn main() !void {
const io = threaded.io();
const cwd = std.Io.Dir.cwd();
const dir = try cwd.openDir(io, "..", .{ .iterate = true }); // change to root later
const dir = try cwd.openDir(io, ".", .{ .iterate = true }); // change to root later
defer dir.close(io);
var iterate = dir.iterate();
+6 -2
View File
@@ -3,10 +3,10 @@ const classify = @import("classify.zig");
pub fn organize(io: std.Io, dir: std.Io.Dir, name: []const u8) !void {
const category = classify.classify(name);
try ensureCategoryDir(io, dir, category);
try placeFile(io, dir, category, name);
}
fn ensureCategoryDir(io: std.Io, dir: std.Io.Dir, category: classify.Category) !void {
fn placeFile(io: std.Io, dir: std.Io.Dir, category: classify.Category, name: []const u8) !void {
const dest = switch (category) {
.image => "Pictures",
.document => "Documents",
@@ -17,4 +17,8 @@ fn ensureCategoryDir(io: std.Io, dir: std.Io.Dir, category: classify.Category) !
};
try dir.createDirPath(io, dest);
var buf: [std.fs.max_path_bytes]u8 = undefined;
const path = try std.fmt.bufPrint(&buf, "{s}/{s}", .{ dest, name });
try dir.rename(name, dir, path, io);
}