列出指定目錄下在過去一小時內被修改的檔案

2021-06-22 11:24:51 字數 700 閱讀 7070

要求: 輸出該路徑下所有當前時刻起前一小時內被修改的檔案及其對應的最後被修改時間。

知識點:

#include

此函式會返回從公元2023年1月1日的utc時間從0時0分0秒算起到現在所經過的秒數。如果t 並非空指標的話,此函式也會將返回值存到t指標所指的記憶體。

**:#include

#include

#include

#include

#include

#include

#include

#include

#define size 1024

int dir_run(char *path)

struct stat st;

struct dirent *entry;

char fullpath[size];

while((entry = readdir(dir)) != null)

sprintf(fullpath, "%s/%s", path, entry->d_name);     

if(lstat(fullpath, &st) != 0)

if(s_isdir(st.st_mode))

else

{int nowtime = time((time_t*)null);

if((nowtime-(st.st_mtime))<=3600)

列出指定目錄下所有檔名

要求 絕對路徑名做輸入引數,列印輸出該路徑下所有檔名 知識點 開啟目錄函式 dir opendir const char path 讀取目錄函式 struct dirent readdir dir dir 返回下乙個目錄項的指標。include include dirent結構體定義如下 struc...

列出指定目錄下的所有檔案的絕對路徑

要求 指定目錄路徑做輸入引數,列印輸出該路徑下所有檔案的絕對路徑使用非遞迴方式 知識點 絕對路徑由指定目錄的絕對路徑加上檔案的相對路徑得到 使用sprintf 建立絕對路徑int sprintf char buffer,const char format,argument buffer char型指...

列出指定目錄下所有可被其他使用者執行的檔案

知識點 stat中的st mode中包含了檔案的訪問許可權位,共有9個 s irusr 使用者讀 s iwusr 使用者寫 s ixusr 使用者執行 s irgrp 組成員讀 s iwgrp 組成員寫 s ixgrp 組成員執行 s iroth 其他使用者讀 s iwoth 其他使用者寫 s ix...