Minor changes

- Added hidden support for ignoring the warning and license disclaimer when the program starts;
- Made changes based on issue #3.
This commit is contained in:
luca0N! 2020-06-19 13:13:14 -03:00
parent 0cd02d1752
commit 3537a786bd
No known key found for this signature in database
GPG Key ID: 9F1B99B522287CAB
3 changed files with 36 additions and 18 deletions

7
cfg.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef LCFG
#define LCFG
#define PATH_LICENSE ".\\LICENSE"
#define PATH_CFG ".\\cfg\\cfg.ini"
#endif

View File

@ -28,9 +28,10 @@
; Após execução, não será possível restaurar os arquivos removidos. ; Após execução, não será possível restaurar os arquivos removidos.
; ;
[Pastas] [Pastas]
; Formato necessário: <Caminho>\ ; Formato necessário: <Caminho>\
Pastas=3 Pastas=3
Pasta1=%tmp%\ Pasta1=%tmp%
Pasta2=C:\Windows\Temp\ Pasta2=C:\Windows\Temp\
Pasta3=C:\Windows\Prefetch\ Pasta3=C:\Windows\Prefetch\

26
main.c
View File

@ -19,6 +19,7 @@
*/ */
#include "about.h" #include "about.h"
#include "str.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. // 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" // #include "colors.h"
@ -30,7 +31,7 @@
// Removes a directory using the Windows shell // Removes a directory using the Windows shell
int shellRemoveDir(LPCTSTR dirPath){ int shellRemoveDir(LPCTSTR dirPath){
// Remove the directory // 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 // Append null to the end of the path
// Double null terminated path string // Double null terminated path string
@ -38,7 +39,12 @@ int shellRemoveDir(LPCTSTR dirPath){
strcpy(dntps, dirPath); strcpy(dntps, dirPath);
strcat(dntps, "\\\0"); 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, NULL,
FO_DELETE, FO_DELETE,
dntps, dntps,
@ -47,7 +53,7 @@ int shellRemoveDir(LPCTSTR dirPath){
0, 0,
0, 0,
"" ""
}; };*/
return SHFileOperation(&dir); return SHFileOperation(&dir);
} }
@ -57,7 +63,7 @@ int printLicense(int full){
printf("%s\n", LICENSE); printf("%s\n", LICENSE);
return 0; return 0;
} else { } else {
FILE* flic = fopen("./LICENSE", "r"); FILE* flic = fopen(PATH_LICENSE, "r");
if (flic == NULL){ if (flic == NULL){
printf("%s\n", STR_ERROR_LIC); printf("%s\n", STR_ERROR_LIC);
return -1; return -1;
@ -71,9 +77,9 @@ int printLicense(int full){
// Gets the user defined directories // Gets the user defined directories
void getAdditionalDirs(){ void getAdditionalDirs(){
printf("%s\n", STR_FETCHING_ADD_DIRS); printf("\n%s\n", STR_FETCHING_ADD_DIRS);
int 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); printf("%s %d\n", STR_DIR_COUNT, dirs);
fflush(stdout); fflush(stdout);
for(unsigned short x = 0; x < dirs; x++){ for(unsigned short x = 0; x < dirs; x++){
@ -82,7 +88,7 @@ void getAdditionalDirs(){
strcat(dirKey, &intPtr); strcat(dirKey, &intPtr);
_TCHAR currentPath[128]; _TCHAR currentPath[128];
GetPrivateProfileString("Pastas", dirKey, "null", currentPath, 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); printf("%s [%s] %s\n", STR_FOUND_DIR, dirKey, currentPath);
cleanDir(currentPath); cleanDir(currentPath);
} }
@ -146,7 +152,10 @@ int main(void){
printf("%s\n%s %d, %s\n", STR_LN, PROGRAM_NAME, PROGRAM_SEASON, PROGRAM_VERSION); 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); printf("%s\n%s\n\n", PROGRAM_COPYRIGHT, STR_LN);
printf("%s\n", STR_USE_WARNING); 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; char in;
fflush(stdout); fflush(stdout);
@ -157,6 +166,7 @@ int main(void){
return -2; return -2;
if (in != 's' && in != 'S' && in != 'y' && in != 'Y') if (in != 's' && in != 'S' && in != 'y' && in != 'Y')
return 0; return 0;
}
getAdditionalDirs(); getAdditionalDirs();
return 0; return 0;
} }