1 Star 0 Fork 0

徐海文/ls

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
mystat.cpp 1.21 KB
Copy Edit Raw Blame History
徐海文 authored 2021-11-04 09:16 +08:00 . mystat.c
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
#include<time.h>
#include<sys/stat.h>
#define MAXLEN 256
struct stat *s;
int main(int argc,char **argv){
s=(struct stat *)malloc(sizeof (struct stat));
stat(argv[1],s);
printf("文件:%s\n",argv[1]);
printf("大小:%-10ld 块:%-10ld IO块:%-7ld ",s->st_size,s->st_blocks,s->st_blksize);
switch (s->st_mode & S_IFMT)
{
case S_IFBLK: printf("块设备\n");
break;
case S_IFCHR: printf("character device\n");
break;
case S_IFDIR: printf("目录\n");
break;
case S_IFIFO: printf("FIFO/管道\n");
break;
case S_IFLNK: printf("符号链接\n");
break;
case S_IFREG: printf("普通文件\n");
break;
case S_IFSOCK: printf("socket\n");
break;
default: printf("未知?\n"); break;
}
printf("设备:%-10ld Inode:%-10ld 硬链接:%ld\n",s->st_dev,s->st_ino,s->st_nlink);
printf("权限: Uid:%d Gid:%d\n",s->st_uid,s->st_gid);
printf("最近访问:%s",ctime(&s->st_ctime));
printf("最近更改:%s",ctime(&s->st_atime));
printf("最近改动:%s",ctime(&s->st_mtime));
printf("创建时间:-\n");
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hai_wen_xu/ls.git
git@gitee.com:hai_wen_xu/ls.git
hai_wen_xu
ls
ls
master

Search