Searchmination of non-working files



  • Write a program that finds faillas built at a non-working time.

    I have no idea how to do this. I know how to look for files, but I have no idea how. ♪ ♪

    I guess the files that were created until there was nobody behind the computer. Can anyone help?



  • #include <locale.h> 
    #include <malloc.h> 
    #include <io.h> 
    #include <time.h>
    
    #define HOUR_START  16
    #define HOUR_FINISH 10
    
    void listdir(char *root) { 
        _finddata_t fd; 
        int rc; 
        long hFile; 
        char mask[260]; 
        char subdir[260]; 
        struct tm *ti;
    
        sprintf(mask, "%s\\*.*", root); 
        for( rc = (hFile = _findfirst(mask, &fd)); rc != -1; rc = _findnext(hFile, &fd) ) { 
            if ( fd.name[0] != '.' ) { 
                if ( fd.attrib & _A_SUBDIR ) { 
                    sprintf(subdir, "%s\\%s", root, fd.name); 
                    listdir(subdir); 
                } 
                else {
                    ti = localtime (&(fd.time_create));
                    if ( (ti->tm_hour >= HOUR_START) || (ti->tm_hour < HOUR_FINISH) )
                        printf("\n%s\\%s %02d:%02d:%02d", root, fd.name, ti->tm_hour, ti->tm_min, ti->tm_sec); 
                }
            } 
        } 
    }
    
    int main() { 
        char root[260] = "c:\\temp";
    
        setlocale(LC_ALL, "Russian");
        listdir(root); 
        return 0; 
    }
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2