refactor(utils): move countEntries from macos utils in common utils
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const utils = @import("utils.zig");
|
const utils = @import("../utils.zig");
|
||||||
|
|
||||||
pub fn getPackagesInfo(allocator: std.mem.Allocator) ![]const u8 {
|
pub fn getPackagesInfo(allocator: std.mem.Allocator) ![]const u8 {
|
||||||
var packages_info = std.array_list.Managed(u8).init(allocator);
|
var packages_info = std.array_list.Managed(u8).init(allocator);
|
||||||
|
|||||||
@@ -23,17 +23,3 @@ pub fn cfTypeRefToZigString(allocator: std.mem.Allocator, cf_type_ref: c_iokit.C
|
|||||||
|
|
||||||
return allocator.realloc(buffer, actual_len);
|
return allocator.realloc(buffer, actual_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn countEntries(dir_path: []const u8) !usize {
|
|
||||||
var dir = try std.fs.openDirAbsolute(dir_path, .{ .iterate = true });
|
|
||||||
defer dir.close();
|
|
||||||
|
|
||||||
var count: usize = 0;
|
|
||||||
var iter = dir.iterate();
|
|
||||||
|
|
||||||
while (try iter.next()) |_| {
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -125,3 +125,17 @@ pub fn readFile(allocator: std.mem.Allocator, file: std.fs.File, size: usize) ![
|
|||||||
|
|
||||||
return allocator.dupe(u8, data);
|
return allocator.dupe(u8, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn countEntries(dir_path: []const u8) !usize {
|
||||||
|
var dir = try std.fs.openDirAbsolute(dir_path, .{ .iterate = true });
|
||||||
|
defer dir.close();
|
||||||
|
|
||||||
|
var count: usize = 0;
|
||||||
|
var iter = dir.iterate();
|
||||||
|
|
||||||
|
while (try iter.next()) |_| {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user