Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<windows.h>
- int main(int argc, char** argv);
- void dirListFiles(const char* startDir);
- const bigFileSize = 1024*1024*1024-1;
- int numOfBigFiles = 0;
- FILETIME dateCreated;
- int main(int argc, char** argv)
- {
- const char* startDir = "C:\\";
- dirListFiles(startDir);
- printf("Big files: %d", numOfBigFiles);
- SYSTEMTIME st;
- char szLocalDate[255];
- FileTimeToLocalFileTime(&dateCreated, &dateCreated);
- FileTimeToSystemTime(&dateCreated, &st);
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szLocalDate, 255);
- printf("Najstarija dat %s\n", szLocalDate);
- system("pause");
- return 0;
- }
- void dirListFiles(const char* startDir)
- {
- HANDLE hFind;
- WIN32_FIND_DATA wfd;
- char path[MAX_PATH];
- sprintf(path, "%s\\*", startDir);
- fprintf(stdout, "In Directory \"%s\"\n\n", startDir);
- if ((hFind = FindFirstFile(path, &wfd)) == INVALID_HANDLE_VALUE)
- {
- fprintf(stderr, "FindFirstFile failed on path = \"%s\"\n", path);
- }
- BOOL cont = TRUE;
- while (cont == TRUE)
- {
- if ((strncmp(".", wfd.cFileName, 1) != 0) && (strncmp("..", wfd.cFileName, 2) != 0) && (strncmp("$", wfd.cFileName, 1) != 0) && (strncmp("System", wfd.cFileName, 6) != 0) && (strncmp("Documents", wfd.cFileName, 9) != 0) && (strncmp("MSOCache", wfd.cFileName, 8) != 0))
- {
- if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- sprintf(path, "%s\\%s", startDir, wfd.cFileName);
- dirListFiles(path);
- }
- else
- {
- if (wfd.nFileSizeHigh != 0 || wfd.nFileSizeLow>bigFileSize)
- {
- numOfBigFiles++;
- }
- if (dateCreated.dwHighDateTime == 0 && dateCreated.dwLowDateTime == 0)
- {
- dateCreated = wfd.ftCreationTime;
- }
- else if (wfd.ftCreationTime.dwHighDateTime < dateCreated.dwHighDateTime || (wfd.ftCreationTime.dwHighDateTime == dateCreated.dwHighDateTime && wfd.ftCreationTime.dwLowDateTime < dateCreated.dwLowDateTime))
- dateCreated = wfd.ftCreationTime;
- }
- }
- cont = FindNextFile(hFind, &wfd);
- }
- if (GetLastError() != ERROR_NO_MORE_FILES)
- {
- fprintf(stderr, "FindNextFile died for some reason; path = \"%s\"\n", path);
- abort();
- }
- if (FindClose(hFind) == FALSE)
- {
- fprintf(stderr, "FindClose failed\n");
- abort();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement