本文介绍了为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:这是 * syscall.Dir 类型.继续阅读以获取详细信息.

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.Stat ,基本上,它只是 stat . syscall.Stat 需要一个字节缓冲区能够写入.对该缓冲区进行一点处理(有关详细信息,请参见 dirstat ),然后将其放入 syscall.UnmarshalDir ,这就是发生魔术的地方.该文档指出,它从缓冲区解码单个9P状态消息",并返回>> * 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在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 05:20