📄 restore.cpp
字号:
/*********************************************************************************** In the name of Almighty ** ** Restore.cpp : Robocup 3D Soccer Simulation Team Zigorat ** (This team was previously named Gcyrus) ** ** Date: 03/20/2007 ** Author: Mahdi Hamdarsi ** Comments: This file restores a backup to the original place ** ***********************************************************************************//*! \file restore.cpp<pre><b>File:</b> restore.cpp<b>Project:</b> Robocup Soccer Simulation Team: Zigorat<b>Authors:</b> Mahdi Hamdarsi<b>Created:</b> 03/20/2007<b>Last Revision:</b> $ID$<b>Contents:</b> This file restores a backup to the original place<hr size=2><h2><b>Changes</b></h2><b>Date</b> <b>Author</b> <b>Comment</b>03/22/2007 Mahdi Initial version created</pre>*/#include <stdio.h>#include <stdlib.h>#define tmp_file "zigorat.tar.gz" /*!< Temperory filename for restoring archive */#define tmp_dir "/root/Desktop/tmpxxxxxxx" /*!< Temperory directory name to restore archive *//*! This is the main function of the program, parses the arguments, prepares archive and restoes it. \param argc Argument count of application \param argv Arguments of application */int main(int argc, char *argv[]){ if( argc != 2 ) { printf("Wrong number of arguments passed, exiting now...\n"); return 1; } FILE *file = fopen(argv[1], "r"); if(!file) { printf("File Not Found:'%s'\n", argv[1]); return 2; } fclose(file); char str[512] = ""; sprintf(str, "mkdir -p %s", tmp_dir); if(system(str)) { printf("Couldn't create a temperory directory\n"); return 3; } sprintf(str, "cp %s %s/%s", argv[1], tmp_dir, tmp_file); if(system(str)) { printf("Couldn''t copy the selected file\n"); return 4; } sprintf(str, "tar -C %s -xf %s/%s", tmp_dir, tmp_dir, tmp_file); if(system(str)) { printf("Couldn''t extract the selected file\n"); return 5; } sprintf(str, "mv %s/zigorat-backup ~/", tmp_dir); if(system(str)) { printf("Couldn''t move the project\n"); return 6; } sprintf(str, "rm -rf /root/Zigorat/"); if(system(str)) { printf("Couldn''t remove old project\n"); return 7; } if(system("mv ~/zigorat-backup ~/Zigorat")) { printf("Couldn''t rename project\n"); return 8; } sprintf(str, "rm -rf %s", tmp_dir); if(system(str)) { printf("Couldn''t remove backup files\n"); return 9; } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -