From a96bac17562ff4a1974e52fae333c788d4a77138 Mon Sep 17 00:00:00 2001
From: luca0N! <63941044+luca0N@users.noreply.github.com>
Date: Mon, 4 May 2020 00:11:13 -0300
Subject: [PATCH] Added INI cfg
Signed-off-by: luca0N! <63941044+luca0N@users.noreply.github.com>
---
cfg/pastas.ini | 17 ++++++++
main.c | 107 +++++++++++++++++++++++++------------------------
str.h | 5 ++-
3 files changed, 75 insertions(+), 54 deletions(-)
create mode 100644 cfg/pastas.ini
diff --git a/cfg/pastas.ini b/cfg/pastas.ini
new file mode 100644
index 0000000..f2d8e58
--- /dev/null
+++ b/cfg/pastas.ini
@@ -0,0 +1,17 @@
+;
+; ┌──┐ │ ┌── ┌──┐ ─┬─ ┌──┐ │
+; ├──┤ │ ├─ ├──┘ │ ├──┤ │
+; │ │ └── └── │ \ │ │ │ •
+;
+; ALERTA!
+;
+; O limpador do luca0N! vai limpar as pastas especificadas abaixo.
+; Tome cuidado! Certifique-se de que nenhuma pasta indesejada esteja listada abaixo.
+; Após execução, não será possível restaurar os arquivos removidos.
+;
+
+[Pastas]
+Pastas=3
+Pasta1=%appdata%
+Pasta2=%tmp%
+Pasta3=C:\Windows\Temp\
\ No newline at end of file
diff --git a/main.c b/main.c
index f5de7f3..8e51985 100644
--- a/main.c
+++ b/main.c
@@ -1,81 +1,84 @@
/*
- limpador do luca0N! 3
- Copyright (C) 2020 luca0N!
+ limpador do luca0N! 3
+ Copyright (C) 2020 luca0N!
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
- Contact me by e-mail via
+ Contact me by e-mail via
*/
#include "about.h"
#include "str.h"
#include "colors.h"
+#include
#include
int printLicense(int full){
- if (full == 0) {
- printf("%s\n", LICENSE_0);
- printf("%s\n", LICENSE_1);
- printf("%s\n", LICENSE_2);
- printf("%s\n", LICENSE_3);
- return 0;
- } else {
- FILE* flic = fopen("./LICENSE", "r");
- if (flic == NULL){
- printf("%s\n", STR_ERROR_LIC);
- return -1;
- }
- char c;
- while ((c = fgetc(flic)) != EOF) {
- printf("%c", c);
- }
- }
+ if (full == 0) {
+ printf("%s\n", LICENSE_0);
+ printf("%s\n", LICENSE_1);
+ printf("%s\n", LICENSE_2);
+ printf("%s\n", LICENSE_3);
+ return 0;
+ } else {
+ FILE* flic = fopen("./LICENSE", "r");
+ if (flic == NULL){
+ printf("%s\n", STR_ERROR_LIC);
+ return -1;
+ }
+ char c;
+ while ((c = fgetc(flic)) != EOF) {
+ printf("%c", c);
+ }
+ }
}
void getAdditionalDirs(){
- printf("%sRecolhendo pastas adicionais...\n", ANSI_COLOR_CYAN);
- FILE* adf = fopen("./adf.txt", "r");
-
+ printf("%sRecolhendo pastas adicionais...\n", ANSI_COLOR_CYAN);
+ //FILE* adf = fopen("./adf.txt", "r");
+ int dirs;
+ dirs = GetPrivateProfileInt("Pastas", "Pastas", 3, ".\\cfg\\pastas.ini");
+ printf("%s %d\n", STR_DIR_COUNT, dirs);
}
void cleanLoadedDirs(){
- printf("%s%s...\n", ANSI_COLOR_CYAN, STR_CLEANING_DIRS);
+ printf("%s%s\n", ANSI_COLOR_CYAN, STR_CLEANING_DIRS);
- // TODO: Limpar pastas.
+ // TODO: Limpar pastas.
}
int main(void){
- printLicense(0);
+ printLicense(0);
- printf("--------------------\n%s %d, %s\n", PROGRAM_NAME, PROGRAM_SEASON, PROGRAM_VERSION);
- printf("%s\n--------------------\n\n", PROGRAM_COPYRIGHT);
+ printf("--------------------\n%s %d, %s\n", PROGRAM_NAME, PROGRAM_SEASON, PROGRAM_VERSION);
+ printf("%s\n--------------------\n\n", PROGRAM_COPYRIGHT);
- printf("%s%s\n", ANSI_COLOR_YELLOW, STR_USE_WARNING);
- const char* in;
- //printf(ANSI_COLOR_RESET);
- fflush(stdout);
+ printf("%s%s\n", ANSI_COLOR_YELLOW, STR_USE_WARNING);
+ char in;
+ printf(ANSI_COLOR_RESET);
+ fflush(stdout);
- scanf("%c", &in);
+ scanf("%c", &in);
- if (in == 'w' || in == 'c')
- if (printLicense(1) != 0)
- return 0;
+ if (in == 'w' || in == 'c')
+ if (printLicense(1) != 0)
+ return 0;
- if (in != 's' && in != 'S' && in != 'y' && in != 'Y')
- return 0;
-
- //getAdditionalDirs();
- cleanLoadedDirs();
- return 0;
+ if (in != 's' && in != 'S' && in != 'y' && in != 'Y')
+ return 0;
+ getAdditionalDirs();
+ cleanLoadedDirs();
+ printf("%s\n", ANSI_COLOR_RESET);
+ return 0;
}
\ No newline at end of file
diff --git a/str.h b/str.h
index b516f8a..0695da5 100644
--- a/str.h
+++ b/str.h
@@ -25,8 +25,9 @@
#define STR_FETCHING_ADD "Recolhendo pastas adicionais..."
#define STR_CLEANING_DIRS "Limpando pastas carregadas..."
-#define STR_REMOVED_FILE "[Arquivo removido] "
-#define STR_REMOVED_DIR "[Pasta removida] "
+#define STR_REMOVED_FILE "[Arquivo removido]"
+#define STR_REMOVED_DIR "[Pasta removida]"
+#define STR_DIR_COUNT "[Contagem de pastas]"
#define STR_ERROR_LIC "Falha ao ler arquivo de licença. Visite para mais informações."