From cefd122c194dc34c581fd78189c8c9df0ffcb606 Mon Sep 17 00:00:00 2001 From: aixiao Date: Fri, 15 Apr 2022 14:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E4=BC=98=E9=9B=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mv.c | 94 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/mv.c b/mv.c index 29c9ee6..10ae669 100644 --- a/mv.c +++ b/mv.c @@ -378,6 +378,48 @@ static char *read_config(char *config_file, char *buffer) return strcpy(buffer, temp_buffer); } +// 处理参数 +int process_argv(int argc, char *argv[], char **argvs) +{ + char delete_path[270]; + memset(delete_path, 0, 270); + read_config("/etc/rm_.conf", delete_path); // 如果有配置文件存在, 读取配置文件, 如果读取配置文件失败默认使用"/tmp/"目录来当作垃圾桶目录 + //printf("%s", delete_path); + + char mkdir_s[270]; + strcpy(mkdir_s, "mkdir -p "); + strcat(mkdir_s, delete_path); + //printf("%s\n", mkdir_s); + + if (!access(delete_path, 0)) { + ;//printf("%s EXISITS!\n", delete_path); + } + else + { + printf("%s DOESN'T EXISIT!\n", delete_path); + if (-1 == system("mount -o remount,rw /")) { // 调用mount命令改变根目录读写权限 + perror("system mount"); + } + if (-1 == system(mkdir_s)) { // 调用mkdir命令创建不存在的垃圾桶目录 + perror("system mkdir"); + } else { + printf("%s Directory Created Successfully!\n", delete_path); + } + } + + for (int i=0; i