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:
parent
0cd02d1752
commit
3537a786bd
|
@ -0,0 +1,7 @@
|
|||
#ifndef LCFG
|
||||
#define LCFG
|
||||
|
||||
#define PATH_LICENSE ".\\LICENSE"
|
||||
#define PATH_CFG ".\\cfg\\cfg.ini"
|
||||
|
||||
#endif
|
|
@ -28,9 +28,10 @@
|
|||
; Após execução, não será possível restaurar os arquivos removidos.
|
||||
;
|
||||
|
||||
|
||||
[Pastas]
|
||||
; Formato necessário: <Caminho>\
|
||||
Pastas=3
|
||||
Pasta1=%tmp%\
|
||||
Pasta1=%tmp%
|
||||
Pasta2=C:\Windows\Temp\
|
||||
Pasta3=C:\Windows\Prefetch\
|
26
main.c
26
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);
|
||||
}
|
||||
|
@ -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\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;
|
||||
fflush(stdout);
|
||||
|
||||
|
@ -157,6 +166,7 @@ int main(void){
|
|||
return -2;
|
||||
if (in != 's' && in != 'S' && in != 'y' && in != 'Y')
|
||||
return 0;
|
||||
}
|
||||
getAdditionalDirs();
|
||||
return 0;
|
||||
}
|
Reference in New Issue