Добавьте файлы проекта.

This commit is contained in:
Денис Урнев 2024-01-10 21:52:05 +03:00
parent 039fa18453
commit 5b3ccddb34
4 changed files with 509 additions and 0 deletions

321
main.c Normal file
View File

@ -0,0 +1,321 @@
#define _CRT_SECURE_NO_WARNINGS
#define _UNICODE
#define UNICODE
#include <windows.h>
#include <direct.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <tchar.h>
#include <locale.h>
#include <string.h>
#include <wchar.h>
#include <sys/types.h>
#include <sys/stat.h>
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);
}
}

View File

@ -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

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{1032e0bd-4677-43be-840d-19525f944b69}</ProjectGuid>
<RootNamespace>Фигнякакаято</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Исходные файлы">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Файлы заголовков">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
</Project>