diff --git a/main.c b/main.c new file mode 100644 index 0000000..bb91320 --- /dev/null +++ b/main.c @@ -0,0 +1,321 @@ + +#define _CRT_SECURE_NO_WARNINGS +#define _UNICODE +#define UNICODE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + + +void printBinary(DWORD num); +void printTypeDrive(); +void printFileAtrib(); +void printFindFileData(); +void printSystemPath(); +void printTimeFile(); +void printSetTimeFile(); +void printCreateDirectory(); +void printReadFile(); + +int main(void) +{ + // UNICODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + const wchar_t str[] = L"help"; + const wchar_t str1[] = L"exit"; + const wchar_t str2[] = L"typeD"; + const wchar_t str3[] = L"printD"; + const wchar_t str4[] = L"fileA"; + const wchar_t str5[] = L"findF"; + const wchar_t str6[] = L"systemD"; + const wchar_t str7[] = L"fileTime"; + const wchar_t str8[] = L"setFileTime"; + const wchar_t str9[] = L"createDirect"; + const wchar_t str10[] = L"readFile"; + _setmode(_fileno(stdin), _O_U16TEXT); + _setmode(_fileno(stdout), _O_U16TEXT); + _setmode(_fileno(stderr), _O_U16TEXT); + wchar_t comand[50]; + //setlocale(LC_ALL, ".UTF8"); + _tprintf(_T(", \"\"\n")); + while (1) { + _tprintf(_T(" : ")); + fgetws(comand,sizeof(comand), stdin); + comand[wcslen(comand) - 1] = 0; + if(!wcscmp(comand, str)) { + _tprintf(_T(" , - (\n")); + } + else if (!wcscmp(comand, str3)) { + DWORD uDriveMask = GetLogicalDrives(); + printBinary(uDriveMask); + } + else if (!wcscmp(comand, str4)) { + printFileAtrib(); + } + else if (!wcscmp(comand, str2)) { + printTypeDrive(); + } + else if (!wcscmp(comand, str5)) { + printFindFileData(); + } + else if (!wcscmp(comand, str6)) { + printSystemPath(); + } + else if (!wcscmp(comand, str7)) { + printTimeFile(); + } + else if (!wcscmp(comand, str8)) { + printSetTimeFile(); + } + else if (!wcscmp(comand, str9)) { + printCreateDirectory(); + } + else if (!wcscmp(comand, str10)) { + printReadFile(); + } + else if (!wcscmp(comand, str1)) { + _tprintf(_T(" !\n")); + break; + } + else { + _tprintf(_T(" !\n")); + + } + } + return 0; + +} + + + +void printFileAtrib() { + _tprintf(_T(" : ")); + wchar_t filePath[1024]; + fgetws(filePath, sizeof(filePath), stdin); + filePath[wcslen(filePath) - 1] = 0; + int fileAttributes = GetFileAttributes(filePath); + + if (fileAttributes == -1) + { + _tprintf(_T("\n")); + } + else + { + if (fileAttributes & FILE_ATTRIBUTE_ARCHIVE) + { + _tprintf(_T("\n")); + } + if (fileAttributes & FILE_ATTRIBUTE_COMPRESSED) + { + _tprintf(_T("\n")); + } + if (fileAttributes & FILE_ATTRIBUTE_READONLY) { + _tprintf(_T(" \n")); + } + if (fileAttributes & FILE_ATTRIBUTE_DEVICE) {} + } +} + + +void printTypeDrive(){ + TCHAR driveName[] = _T("C:\\"); + _tprintf(_T(" : ")); + _tscanf(_T("%c"), driveName); + _tprintf(_T(" a: %s\n"), driveName); + UINT type = GetDriveType(driveName); + + switch (type) + { + case DRIVE_NO_ROOT_DIR: + _tprintf(_T(" !!!\n")); + break; + case DRIVE_REMOVABLE: + _tprintf(_T(" \n")); + break; + case DRIVE_FIXED: + _tprintf(_T(" \n")); + break; + default: + break; + } +} + +void printBinary(DWORD num) +{ + _tprintf(_T(" : ")); + for (BYTE i = 0; i < 28; i++) + { + if (num & 1) { + _tprintf(_T("%c"), (_T('A') + i)); // L'A' + i + + } + num >>= 1; + + } + _tprintf(_T("\n")); +} +void printFindFileData() { + _tprintf(_T(" : ")); + WIN32_FIND_DATA findFileData; + wchar_t filePath[1024]; + fgetws(filePath, sizeof(filePath), stdin); + filePath[wcslen(filePath) - 1] = 0; + HANDLE hFind = FindFirstFile(filePath, &findFileData); + if (hFind == INVALID_HANDLE_VALUE) + { + _tprintf(_T("- ")); + } + else + { + do + { + _tprintf(_T("%s\n"), findFileData.cFileName); + } while (FindNextFile(hFind, &findFileData)); + + FindClose(hFind); + } +} +void printSystemPath() { + wchar_t system_directory[MAX_PATH]; + GetSystemDirectory(system_directory, MAX_PATH); + + _tprintf(_T(" : %s\n"), system_directory); + +} + +void printTimeFile() { + _tprintf(_T(" : ")); + wchar_t filename[1024]; + fgetws(filename, sizeof(filename), stdin); + filename[wcslen(filename) - 1] = 0; + FILETIME date_soz, fileInfo1; + SYSTEMTIME systemTime; + + HANDLE hFile = CreateFile( + filename, + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + + if (hFile == INVALID_HANDLE_VALUE) { + _tprintf(_T(" \n")); + } + else { + GetFileTime(hFile, &date_soz, &fileInfo1, NULL); + FileTimeToSystemTime(&date_soz, &systemTime); + _tprintf(_T(" c : %d.%d.%d %d:%d:%d\n"), + systemTime.wDay, systemTime.wMonth, systemTime.wYear, + systemTime.wHour + 3, systemTime.wMinute, systemTime.wSecond + ); + FileTimeToSystemTime(&fileInfo1, &systemTime); + _tprintf(_T(" : %d.%d.%d %d:%d:%d\n"), + systemTime.wDay, systemTime.wMonth, systemTime.wYear, + systemTime.wHour + 3, systemTime.wMinute, systemTime.wSecond + ); + } +} + + void printSetTimeFile() { + _tprintf(_T(" : ")); + wchar_t filename[1024]; + fgetws(filename, sizeof(filename), stdin); + filename[wcslen(filename) - 1] = 0; + FILETIME date_soz, fileInfo1; + SYSTEMTIME systemTime; + _tprintf(_T(" ( Enter): ")); + wscanf(L"%d", &systemTime.wYear); + wscanf(L"%d", &systemTime.wMonth); + wscanf(L"%d", &systemTime.wDay); + wscanf(L"%d", &systemTime.wHour); + wscanf(L"%d", &systemTime.wMinute); + wscanf(L"%d", &systemTime.wSecond); + HANDLE hFile = CreateFile( + filename, + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + + if (hFile == INVALID_HANDLE_VALUE) { + _tprintf(_T(" \n")); + } + else { + + SystemTimeToFileTime(&systemTime, &date_soz); + SetFileTime(hFile, &date_soz, NULL, NULL); + _tprintf(_T(" c : %d.%d.%d\n"), + systemTime.wDay, systemTime.wMonth, systemTime.wYear); + /* FileTimeToSystemTime(&fileInfo1, &systemTime); + _tprintf(_T(" : %d.%d.%d %d:%d:%d\n"), + systemTime.wDay, systemTime.wMonth, systemTime.wYear, + systemTime.wHour + 3, systemTime.wMinute, systemTime.wSecond + );*/ + } + } + + + void printCreateDirectory() { + _tprintf(_T(" : ")); + wchar_t filename[1024]; + fgetws(filename, sizeof(filename), stdin); + filename[wcslen(filename) - 1] = 0; + BOOL bStatus = CreateDirectoryW(filename, NULL); + if (bStatus) return; + DWORD error = GetLastError(); + if (error == ERROR_ALREADY_EXISTS) + _tprintf(_T(" \n")); + else if (error == ERROR_PATH_NOT_FOUND) + _tprintf(_T(" \n")); + + } + void printReadFile() { + _tprintf(_T(" : ")); + wchar_t filename[1024]; + fgetws(filename, sizeof(filename), stdin); + filename[wcslen(filename) - 1] = 0; + + char buffer[MAX_PATH]; + DWORD bytesRead; + int numBytes; + ZeroMemory(buffer, MAX_PATH); + + HANDLE hFile = CreateFile( + filename, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + + if (hFile == INVALID_HANDLE_VALUE) { + _tprintf(_T(" \n")); + } + else { + _tprintf(_T(" : ")); + wscanf(L"%d", &numBytes); + ReadFile(hFile, buffer, numBytes, &bytesRead, NULL); + buffer[bytesRead] = '\0'; + _tprintf(_T(" %d :\n"), bytesRead); + _tprintf(_T("%s\n"), buffer); + } + } \ No newline at end of file diff --git a/Фигня какая-то.sln b/Фигня какая-то.sln new file mode 100644 index 0000000..accf4aa --- /dev/null +++ b/Фигня какая-то.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Фигня какая-то", "Фигня какая-то.vcxproj", "{1032E0BD-4677-43BE-840D-19525F944B69}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1032E0BD-4677-43BE-840D-19525F944B69}.Debug|x64.ActiveCfg = Debug|x64 + {1032E0BD-4677-43BE-840D-19525F944B69}.Debug|x64.Build.0 = Debug|x64 + {1032E0BD-4677-43BE-840D-19525F944B69}.Debug|x86.ActiveCfg = Debug|Win32 + {1032E0BD-4677-43BE-840D-19525F944B69}.Debug|x86.Build.0 = Debug|Win32 + {1032E0BD-4677-43BE-840D-19525F944B69}.Release|x64.ActiveCfg = Release|x64 + {1032E0BD-4677-43BE-840D-19525F944B69}.Release|x64.Build.0 = Release|x64 + {1032E0BD-4677-43BE-840D-19525F944B69}.Release|x86.ActiveCfg = Release|Win32 + {1032E0BD-4677-43BE-840D-19525F944B69}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7FE803A7-DFC0-4457-9249-0498BDF3FECA} + EndGlobalSection +EndGlobal diff --git a/Фигня какая-то.vcxproj b/Фигня какая-то.vcxproj new file mode 100644 index 0000000..7dc8c26 --- /dev/null +++ b/Фигня какая-то.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {1032e0bd-4677-43be-840d-19525f944b69} + Фигнякакаято + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Фигня какая-то.vcxproj.filters b/Фигня какая-то.vcxproj.filters new file mode 100644 index 0000000..669bc4e --- /dev/null +++ b/Фигня какая-то.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file