Skip to content

Commit

Permalink
copy altsnap.dni if no ini file found in user's folder
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonUnch authored May 25, 2024
1 parent be03cc9 commit ba04c85
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions altsnap.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,24 @@ int WINAPI tWinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, TCHAR *params, int
&& GetEnvironmentVariable(TEXT("APPDATA"), NULL, 0)) {
// .ini file is not in current directorry, and APPDATA exists
// we should look for %APPDATA%\AltSnap\AltSnap.ini
GetEnvironmentVariable(TEXT("APPDATA"), inipath, ARR_SZ(inipath));
lstrcat_s(inipath, ARR_SZ(inipath), TEXT("\\AltSnap"));
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(inipath)) {
CreateDirectory(inipath, NULL);
TCHAR userini[MAX_PATH];
GetEnvironmentVariable(TEXT("APPDATA"), userini, ARR_SZ(userini));
lstrcat_s(userini, ARR_SZ(userini), TEXT("\\AltSnap"));
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(userini)) {
CreateDirectory(userini, NULL);
LOG("CreateDirectory(%S)", userini);
}
// Full user ini name.
lstrcat_s(userini, ARR_SZ(userini), TEXT("\\AltSnap.ini"));
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(userini)) {
// Copy AltSnap.dni (Default ini file) if no ini present
lstrcpy_s(&inipath[lstrlen(inipath)-3], 4, TEXT("dni"));
CopyFile(inipath, userini, FALSE); // AltSnap.dni -> AltSnap.ini
LOG("CopyFile(%S -> %S)", inipath, userini);
}
lstrcat_s(inipath, ARR_SZ(inipath), TEXT("\\AltSnap.ini"));
}
MessageBox(NULL, inipath, NULL, 0);

lstrcpy_s(inipath, ARR_SZ(inipath), userini);
}
LOG("ini file: %S", inipath);

// Read parameters on command line
Expand Down

0 comments on commit ba04c85

Please sign in to comment.