diff --git a/cfg.h b/cfg.h new file mode 100644 index 0000000..75c8442 --- /dev/null +++ b/cfg.h @@ -0,0 +1,7 @@ +#ifndef LCFG +#define LCFG + +#define PATH_LICENSE ".\\LICENSE" +#define PATH_CFG ".\\cfg\\cfg.ini" + +#endif \ No newline at end of file diff --git a/cfg/pastas.ini b/cfg/cfg.ini similarity index 98% rename from cfg/pastas.ini rename to cfg/cfg.ini index 2cd74fc..96fd3c0 100644 --- a/cfg/pastas.ini +++ b/cfg/cfg.ini @@ -28,9 +28,10 @@ ; Após execução, não será possível restaurar os arquivos removidos. ; + [Pastas] ; Formato necessário: \ Pastas=3 -Pasta1=%tmp%\ +Pasta1=%tmp% Pasta2=C:\Windows\Temp\ Pasta3=C:\Windows\Prefetch\ diff --git a/main.c b/main.c index ab78c17..e6d123b 100644 --- a/main.c +++ b/main.c @@ -19,6 +19,7 @@ */ #include "about.h" #include "str.h" +#include "cfg.h" // Because this program is currently target at Windows only, the use of ANSI colors are no longer used as of May 5, 2020. // #include "colors.h" @@ -30,7 +31,7 @@ // Removes a directory using the Windows shell int shellRemoveDir(LPCTSTR dirPath){ // Remove the directory - //printf("!! ATTEMPT TO REMOVE %s\\...\n", dirPath); + //printf("!! ATTEMPT TO REMOVE (%d) %s\\...\n", len, shortPath); // Append null to the end of the path // Double null terminated path string @@ -38,7 +39,12 @@ int shellRemoveDir(LPCTSTR dirPath){ strcpy(dntps, dirPath); strcat(dntps, "\\\0"); - SHFILEOPSTRUCT dir = { + SHFILEOPSTRUCT dir = {0}; + dir.wFunc = FO_DELETE; + dir.pFrom = dntps; + dir.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; + dir.fAnyOperationsAborted = 0; + /*dir = { NULL, FO_DELETE, dntps, @@ -47,7 +53,7 @@ int shellRemoveDir(LPCTSTR dirPath){ 0, 0, "" - }; + };*/ return SHFileOperation(&dir); } @@ -57,7 +63,7 @@ int printLicense(int full){ printf("%s\n", LICENSE); return 0; } else { - FILE* flic = fopen("./LICENSE", "r"); + FILE* flic = fopen(PATH_LICENSE, "r"); if (flic == NULL){ printf("%s\n", STR_ERROR_LIC); return -1; @@ -71,9 +77,9 @@ int printLicense(int full){ // Gets the user defined directories void getAdditionalDirs(){ - printf("%s\n", STR_FETCHING_ADD_DIRS); + printf("\n%s\n", STR_FETCHING_ADD_DIRS); int dirs; - dirs = GetPrivateProfileInt("Pastas", "Pastas", 3, ".\\cfg\\pastas.ini"); + dirs = GetPrivateProfileInt("Pastas", "Pastas", 3, PATH_CFG); printf("%s %d\n", STR_DIR_COUNT, dirs); fflush(stdout); for(unsigned short x = 0; x < dirs; x++){ @@ -82,7 +88,7 @@ void getAdditionalDirs(){ strcat(dirKey, &intPtr); _TCHAR currentPath[128]; GetPrivateProfileString("Pastas", dirKey, "null", currentPath, - sizeof(currentPath) / sizeof(currentPath[0]), ".\\cfg\\pastas.ini"); + sizeof(currentPath) / sizeof(currentPath[0]), PATH_CFG); printf("%s [%s] %s\n", STR_FOUND_DIR, dirKey, currentPath); cleanDir(currentPath); } @@ -145,18 +151,22 @@ int main(void){ printf("%s\n%s %d, %s\n", STR_LN, PROGRAM_NAME, PROGRAM_SEASON, PROGRAM_VERSION); printf("%s\n%s\n\n", PROGRAM_COPYRIGHT, STR_LN); + + unsigned int ignoreWarning = GetPrivateProfileInt("Geral", "IgnorarAlerta", 0, PATH_CFG); + unsigned int licenseAccepted = GetPrivateProfileInt("Geral", "AceitarLicença", 0, PATH_CFG); + if (!ignoreWarning || !licenseAccepted){ + printf("%s ", STR_USE_WARNING, ignoreWarning, licenseAccepted); + char in; + fflush(stdout); - printf("%s\n", STR_USE_WARNING); - char in; - fflush(stdout); + scanf("%c", &in); - scanf("%c", &in); - - if (in == 'w' || in == 'c') - if (printLicense(1) != 0) - return -2; - if (in != 's' && in != 'S' && in != 'y' && in != 'Y') - return 0; + if (in == 'w' || in == 'c') + if (printLicense(1) != 0) + return -2; + if (in != 's' && in != 'S' && in != 'y' && in != 'Y') + return 0; + } getAdditionalDirs(); return 0; } \ No newline at end of file