如何使用C获取类似于"ls -la"的文件信息?

ino*_*com 4 c unix struct file

我使用ar.h来定义结构.我想知道如何获取有关文件的信息并将其放入结构中的指定变量中.

struct ar_hdr {
    char ar_name[16];       /* name of this member */
    char ar_date[12];       /* file mtime */
    char ar_uid[6];         /* owner uid; printed as decimal */
    char ar_gid[6];          /* owner gid; printed as decimal */
    char ar_mode[8];        /* file mode, printed as octal   */
    char ar_size[10];       /* file size, printed as decimal */
    char ar_fmag[2];        /* should contain ARFMAG */
};
Run Code Online (Sandbox Code Playgroud)

使用上面定义的结构,我将如何从文件中获取信息 ls -la

-rw-rw----. 1 clean-unix upg40883 368 Oct 29 15:17 testar