为plan9定义Stat_t在哪里? [英] Where is Stat_t defined for plan9?

查看:48
本文介绍了为plan9定义Stat_t在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

plan9 特定于 syscall 的Go代码中,没有像其他 GOOS 那样的 Stat_t . Stat_t 或等价物在哪里定义?

In the plan9 specific Go code for syscall, there is no Stat_t like with other GOOS. Where is Stat_t, or its equivalent defined?

推荐答案

TL; DR:这是

TL;DR: It's the *syscall.Dir type. Read on for details.

Plan9上的 os.Stat 的来源是此处.它会调用 dirstat ,该代码在此处中定义.它将 dirstat 的返回值输入到 fileInfoFromStat 中,该文件在同一文件

The source for os.Stat on Plan9 is here. It calls dirstat, which is defined here. It feeds the return value of dirstat into fileInfoFromStat, which is defined in the same file here.

对于路径(与 * File 对象相对), dirstat 仅调用>> * syscall.Dir .

In the case of paths (as opposed to *File objects), dirstat just calls syscall.Stat, which is basically just a thin wrapper around stat. syscall.Stat expects a byte buffer to be able to write into. This buffer is processed a bit (see dirstat for details), and then fed into syscall.UnmarshalDir, which is where the magic happens. The documentation states that it "decodes a single 9P stat message" from a buffer and returns a *syscall.Dir.

dirstat 将此 * syscall.Dir 传递给 fileInfoFromStat ,然后将其处理为 FileInfo .正是通过 FileInfo 对象上的 Sys()方法获得的 * syscall.Dir 值.

dirstat then passes this *syscall.Dir to fileInfoFromStat, which is what processes it into a FileInfo. It's this *syscall.Dir value that is obtained through the Sys() method on the FileInfo object.

这篇关于为plan9定义Stat_t在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆