mirror of
https://git.aramjonghu.nl/AramJonghu/file-organizer.git
synced 2026-06-06 17:48:23 +02:00
archives support, builds .exe as well now
This commit is contained in:
@@ -19,6 +19,17 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
|
const exe_win = b.addExecutable(.{
|
||||||
|
.name = "file_organizer",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/main.zig"),
|
||||||
|
.target = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .windows }),
|
||||||
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
b.installArtifact(exe_win);
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ pub const Category = enum {
|
|||||||
document,
|
document,
|
||||||
music,
|
music,
|
||||||
video,
|
video,
|
||||||
|
archive,
|
||||||
code,
|
code,
|
||||||
other,
|
other,
|
||||||
};
|
};
|
||||||
@@ -19,6 +20,7 @@ const CategoryMap = [_]CategoryEntry{
|
|||||||
.{ .category = .document, .extensions = &DocumentTypes },
|
.{ .category = .document, .extensions = &DocumentTypes },
|
||||||
.{ .category = .music, .extensions = &MusicTypes },
|
.{ .category = .music, .extensions = &MusicTypes },
|
||||||
.{ .category = .video, .extensions = &VideoTypes },
|
.{ .category = .video, .extensions = &VideoTypes },
|
||||||
|
.{ .category = .archive, .extensions = &ArchiveTypes },
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImageTypes = [_][]const u8{
|
const ImageTypes = [_][]const u8{
|
||||||
@@ -42,6 +44,10 @@ const VideoTypes = [_][]const u8{
|
|||||||
".webm", ".wmv",
|
".webm", ".wmv",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ArchiveTypes = [_][]const u8{
|
||||||
|
".zip", ".rar", ".iso", ".tar", ".gz", ".7z", ".apk", ".cab", ".dar", ".dmg", ".jar", ".pea", ".tar.gz", ".tgz", ".tar.Z", ".tar.bz2", ".tbz2", ".tar.lz", ".tlz", ".tar.xz", ".txz", ".tar.zst",".war", ".zipx",
|
||||||
|
};
|
||||||
|
|
||||||
pub fn classify(name: []const u8) Category {
|
pub fn classify(name: []const u8) Category {
|
||||||
const extension = std.fs.path.extension(name);
|
const extension = std.fs.path.extension(name);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ pub fn main() !void {
|
|||||||
|
|
||||||
const io = threaded.io();
|
const io = threaded.io();
|
||||||
const cwd = std.Io.Dir.cwd();
|
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 });
|
||||||
defer dir.close(io);
|
defer dir.close(io);
|
||||||
|
|
||||||
var iterate = dir.iterate();
|
var iterate = dir.iterate();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ fn placeFile(io: std.Io, dir: std.Io.Dir, category: classify.Category, name: []c
|
|||||||
.document => "Documents",
|
.document => "Documents",
|
||||||
.music => "Music",
|
.music => "Music",
|
||||||
.video => "Videos",
|
.video => "Videos",
|
||||||
|
.archive => "Archives",
|
||||||
.code => "Code",
|
.code => "Code",
|
||||||
.other => return,
|
.other => return,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user