Linux 簡單實現 ls l 命令

2021-08-16 05:04:54 字數 910 閱讀 4281

ls -l命令

系統效果:

列出檔案屬性,許可權,使用者等資訊

簡單實現**:

#include

#include

#include

#include

#include

#include

#include

#include

#include

struct stat sbuf;

struct stat sbuf_dst;

struct stat sbuf_reg;

void print_information(char* file);

void open_dir(char* dir)

else

closedir(pdir);

}}void file_type(mode_t md)//顯示檔案型別函式

void print_information(char* file)

; if(s_islnk(sbuf_reg.st_mode))

printf("\n");

}int main(int argc, char* argv)

if(s_isdir(sbuf.st_mode))

else

}

效果:

總用量顯示與系統不一致,沒搞懂總用量是什麼,網上說是塊檔案的個數,一塊是1024,就是1k,但是檔案大小除以1024也不對,不知道怎麼獲取總用量,希望知道的大神賜教。

Linux詳細實現ls l命令

實現ls l include include include include include include include include include include void file type unsigned char type 獲取檔案型別 void dir count const c...

Linux命令實現(4) ls l

使用了stat 終於實現讀取檔案的詳細資訊 include include include include include include include void do ls char void dostat char void show file info char struct stat vo...

python實現linux下ls l的命令

usr bin env python3 coding utf 8 import os import shutil from stat import import pwd import grp import traceback import time defllist path try for nam...