From 9925cc945d0e0b43478860c64f587585d43ba1c7 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 2 Jul 2013 00:45:47 +0100 Subject: [PATCH] [syslinux] download c32 files in the same directory as the app * Rufus was downloading c32 files in the last directory browsed, which meant that the same file may have had to be downloaded more than once * Closes #154 --- src/msapi_utf8.h | 9 +++++++++ src/net.c | 2 +- src/rufus.c | 10 ++++++---- src/rufus.rc | 10 +++++----- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index 0feeac5a..b187d75d 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -616,6 +616,15 @@ out: return ret; } +static __inline int _chdirU(const char *dirname) +{ + int ret; + wconvert(dirname); + ret = _wchdir(wdirname); + wfree(dirname); + return ret; +} + static __inline FILE* fopenU(const char* filename, const char* mode) { FILE* ret = NULL; diff --git a/src/net.c b/src/net.c index 15f10f25..48c69b4a 100644 --- a/src/net.c +++ b/src/net.c @@ -324,7 +324,7 @@ BOOL DownloadFile(const char* url, const char* file, HWND hProgressDialog) } uprintf("File length: %d bytes\n", dwTotalSize); - fd = fopen(file, "wb"); + fd = fopenU(file, "wb"); if (fd == NULL) { uprintf("Unable to create file '%s': %s\n", file, WinInetErrorString()); goto out; diff --git a/src/rufus.c b/src/rufus.c index e61b6d32..a7aed5b7 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -1043,6 +1043,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) safe_free(iso_path); SetMBRProps(); } else if (!iso_report.has_syslinux_v5) { // This check is for Syslinux v4.x or earlier + _chdirU(app_dir); for (i=0; i