mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Portable Installer: Auto-create the directory specified ont he command line if it does not exist
This commit is contained in:
parent
afb8f797c6
commit
70f7e0438b
@ -499,6 +499,19 @@ static void launch_calibre() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makedirs(LPWSTR path) {
|
||||||
|
WCHAR *p = path;
|
||||||
|
while (*p) {
|
||||||
|
if ((*p == L'\\' || *p == L'/') && p != path && *(p-1) != L':') {
|
||||||
|
*p = 0;
|
||||||
|
CreateDirectory(path, NULL);
|
||||||
|
*p = L'\\';
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
CreateDirectory(path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -521,6 +534,14 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
tgt = argv[1];
|
tgt = argv[1];
|
||||||
automated = true;
|
automated = true;
|
||||||
|
if (!directory_exists(tgt)) {
|
||||||
|
if (GetFullPathName(tgt, MAX_PATH*4, fdest, NULL) == 0) {
|
||||||
|
show_last_error(L"Failed to resolve target folder");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
makedirs(fdest);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tgt = get_directory_from_user();
|
tgt = get_directory_from_user();
|
||||||
if (tgt == NULL) goto end;
|
if (tgt == NULL) goto end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user