mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
[fs] Add missing isFile and isDirectory functions to stat()
This commit is contained in:
@@ -2788,9 +2788,9 @@ pub fn wrap(
|
||||
return null;
|
||||
}
|
||||
|
||||
JavaScript.VirtualMachine.vm.tick();
|
||||
if (comptime maybe_async) {
|
||||
JavaScript.VirtualMachine.vm.tick();
|
||||
|
||||
if (maybe_async) {
|
||||
var promise = JSC.JSInternalPromise.resolvedPromise(ctx.ptr(), result);
|
||||
|
||||
switch (promise.status(ctx.ptr().vm())) {
|
||||
|
||||
@@ -755,7 +755,15 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type {
|
||||
pub const Class = JSC.NewClass(
|
||||
This,
|
||||
.{ .name = name },
|
||||
.{},
|
||||
.{
|
||||
.isFile = .{
|
||||
.rfn = JSC.wrap(This, "isFile", false),
|
||||
},
|
||||
.isDirectory = .{
|
||||
.rfn = JSC.wrap(This, "isDirectory", false),
|
||||
},
|
||||
.finalize = finalize,
|
||||
},
|
||||
.{
|
||||
.dev = .{
|
||||
.get = JSC.To.JS.Getter(This, .dev),
|
||||
@@ -887,6 +895,13 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn isFile(this: *Stats) JSC.JSValue {
|
||||
return JSC.JSValue.jsBoolean(os.S.ISREG(@intCast(os.mode_t, this.mode)));
|
||||
}
|
||||
pub fn isDirectory(this: *Stats) JSC.JSValue {
|
||||
return JSC.JSValue.jsBoolean(os.S.ISDIR(@intCast(os.mode_t, this.mode)));
|
||||
}
|
||||
|
||||
pub fn toJS(this: Stats, ctx: JSC.C.JSContextRef, _: JSC.C.ExceptionRef) JSC.C.JSValueRef {
|
||||
var _this = bun.default_allocator.create(Stats) catch unreachable;
|
||||
_this.* = this;
|
||||
|
||||
Reference in New Issue
Block a user