Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- _TCHAR * SystemTimeToTchar(SYSTEMTIME);
- _TCHAR * FileSizeToTchar(DWORD);
- int _tmain(int argc, _TCHAR* argv[])
- {
- WIN32_FIND_DATAW wfd;
- SYSTEMTIME time;
- if (argc >1)
- {
- for (int i = 1; i < argc ; ++i)
- {
- HANDLE const hFind = FindFirstFileW(argv[i], &wfd);
- setlocale(LC_ALL, "");
- wprintf(L"Contents of directory %s :\n\n",argv[i]);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- do
- {
- _TCHAR type[6]=L" ";
- _TCHAR size[20] = L" ";
- if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )wsprintf(type, L"<DIR>");
- else wsprintf(size,L"%d",wfd.nFileSizeLow);
- FileTimeToSystemTime(&wfd.ftLastWriteTime, &time);
- wprintf(L"%s %s %s %s\n", SystemTimeToTchar(time), type, size , &wfd.cFileName[0]);
- wprintf(L"%s\n",size);
- } while (NULL != FindNextFileW(hFind, &wfd));
- FindClose(hFind);
- }
- }
- }
- else std::cout << "Please, enter directory!\n";
- return 0;
- }
- _TCHAR * SystemTimeToTchar(SYSTEMTIME time)
- {
- _TCHAR str[256];
- _TCHAR second[3];
- _TCHAR minute[3];
- _TCHAR hour[3];
- _TCHAR day[3];
- _TCHAR month[3];
- wsprintf(second, time.wSecond >9 ? L"%d" : L"0%d", time.wSecond);
- wsprintf(minute, time.wMinute >9 ? L"%d" : L"0%d", time.wMinute);
- wsprintf(hour, time.wHour >9 ? L"%d" : L"0%d", time.wHour);
- wsprintf(day, time.wDay >9 ? L"%d" : L"0%d", time.wDay);
- wsprintf(month , time.wMonth >9 ? L"%d" : L"0%d", time.wMonth);
- wsprintf(str, L"%s.%s.%d %s:%s", day,month, time.wYear,hour,minute,second);
- return str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement