Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Purpursarkans committed Sep 5, 2021
1 parent 7ab2b57 commit 4aec6b8
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 111 deletions.
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Используйте IntelliSense, чтобы узнать о возможных атрибутах.
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов.
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Сборка и отладка активного файла",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:\\msys64\\mingw64\\bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Включить автоматическое форматирование для gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe сборка активного файла"
}
]
}
85 changes: 85 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"files.associations": {
"ostream": "cpp",
"string": "cpp",
"iostream": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"cstdint": "cpp",
"cuchar": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ranges": "cpp",
"scoped_allocator": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe сборка активного файла",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\msys64\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Задача создана отладчиком."
}
],
"version": "2.0.0"
}
15 changes: 15 additions & 0 deletions Example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>
#include "Update.hpp"

#define VERSION 2

int main(int argc, char * argv[])
{
update(argc, argv, "https://raw.githubusercontent.com/Purpursarkans/update/main/version", VERSION, "Example");

std::cout << "all update" << std::endl;

system("pause");

return 0;
}
Binary file added Example.exe
Binary file not shown.
57 changes: 57 additions & 0 deletions Update.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef UPDATE_HPP
#define UPDATE_HPP

#include <bits/stdc++.h>

void update(int argc, char *argv[], std::string sVersionUrl, int sVersionI, std::string exeName)
{
static std::string exeNameCopy = exeName + "2";

for (int i = 1; i < argc; i++)
{
std::string temp = argv[i];
if (temp == "-u")
{
std::string copy_ = "copy " + exeNameCopy + ".exe " + exeName + ".exe /Y";
system(copy_.c_str());

std::string start = "start cmd /C \"" + exeName + ".exe -d\"";
system(start.c_str());
exit(0);
}
else if (temp == "-d")
{
std::string remove_ = exeNameCopy + ".exe";
while (remove(remove_.c_str())) {}

std::string start = "start " + exeName + ".exe";
system(start.c_str());
exit(0);
}
}

std::string downloadVersion = "curl -o version -L " + sVersionUrl;
system(downloadVersion.c_str());

std::ifstream rFile("version");
std::string versionS;
std::string downloadUrl;
std::getline(rFile, versionS);
std::getline(rFile, downloadUrl);
int versionI = std::stoi(versionS);

rFile.close();
remove("version");

if (versionI > sVersionI)
{
std::cout << "Need update" << std::endl;
std::cout << "Start update" << std::endl;

std::string curl = "curl -o " + exeNameCopy + ".exe " + "-L " + downloadUrl + " && start cmd /C \"" + exeNameCopy + ".exe -u\"";
system(curl.c_str());
exit(0);
}
}

#endif
69 changes: 0 additions & 69 deletions main.cpp

This file was deleted.

41 changes: 0 additions & 41 deletions update.cbp

This file was deleted.

Binary file removed update.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
2
https://github.com/Purpursarkans/update/blob/main/update.exe?raw=true
https://github.com/Purpursarkans/update/blob/main/Example.exe?raw=true

0 comments on commit 4aec6b8

Please sign in to comment.