c Delete the content specified in the file

zhaozj2021-02-11  224

#include #include #include

Void search_file (char * dir); void clear_file (char * filename1); Dir * DP; struct Dirent * DIRP; char * file; file * fp = null; char n_filename [50]; char o_filename [50] CHAR BUF [80]; Int PID; int stat; char * logbak; char * OPTARG; int main (char * argv []) {

LogDir = "/ usr / local / tmp_file /"; logbak = "/ usr / local / tmp_file2 /"; Printf ("begin now! / n"); search_file (logdir);

}

Void search_file ((DP = OpenDir (DIR)) == null) {Printf ("Directory% S is Not Found! / N", logDir);} / * print err * / while ((( Dirp = readdir (dp))! = null) {OPTARG = DIRP-> D_NAME; / * Printf ("% s / n", opTarg); * / if ((strstr (Optarg, ". htm")! = null ) | (Strstr (Optarg, ")")! = Null) | (strstr (Optarg, ". ASP")! = Null) {

N_FileName [0] = '/ 0'; o_filename [0] = '/ 0'; strcat (o_filename, logdir); strcat (o_filename, "/"); strcat (o_filename, optarg); strcat (n_filename, logbak); STRCAT (N_FileName, Optarg); Printf ("% s / n", o_filename); clear_file (o_filename, n_filename); / * status = rename (o_filename, n_filename); * / printf ("% s% s rename file status: % D / N ", o_filename, n_filename, status);}} / * for every log file * / closedir (dp); Sleep (20);

Void Clear_File (Char * filename, char * filename1) {

转载请注明原文地址:https://www.9cbs.com/read-3541.html

New Post(0)