如何获得类似于&QUOT文件信息; LS -la"使用C? [英] How to get file information similar to "ls -la" using C?

查看:146
本文介绍了如何获得类似于&QUOT文件信息; LS -la"使用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ar.h的定义结构。我想知道我如何会去有关获取有关文件的信息,并把它变成那些指定的变量在结构中。

I am using ar.h for the defining the struct. I was wondering on how I would go about getting information about a file and putting it into those specified variables in the struct.

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 */
};

使用上述定义的结构,我怎么会把从 LS -la

-RW-RW ----。 1清洁UNIX upg40883 368 10月29日15:17 testar

推荐答案

您正在寻找 STAT(2,3p)

You're looking for stat(2,3p).

这篇关于如何获得类似于&QUOT文件信息; LS -la"使用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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