added and verified another condition - both GetDiskFreeSpace and GetDiskFreeSpaceEx require a trailing backslash

this needs a lot of optimization

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5678 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2008-07-12 17:11:38 +00:00
parent 7b3d0cf65b
commit 223ea672e1

View file

@ -982,7 +982,6 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (uMsg == WM_IN_UPDATEMSG || uMsg == WM_NOTIFY_START) if (uMsg == WM_IN_UPDATEMSG || uMsg == WM_NOTIFY_START)
{ {
static char s[NSIS_MAX_STRLEN]; static char s[NSIS_MAX_STRLEN];
char *root;
int error = 0; int error = 0;
int available_set = 0; int available_set = 0;
unsigned total, available; unsigned total, available;
@ -1002,13 +1001,14 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
* This makes sure NTFS mount points are treated properly (#1946112). * This makes sure NTFS mount points are treated properly (#1946112).
* 3. `s' stays valid after the loop for GetDiskFreeSpace. * 3. `s' stays valid after the loop for GetDiskFreeSpace.
* This means there is no cutting beyond what skip_root() returns. * This means there is no cutting beyond what skip_root() returns.
* Or `s' could be recreated when GetDiskFreeSpace is called.
* 4. If GetDiskFreeSpaceEx doesn't exist, GetDiskFreeSpace is used. * 4. If GetDiskFreeSpaceEx doesn't exist, GetDiskFreeSpace is used.
* 5. `dir' is never modified. * 5. Both functions require a trailing backslash
* 6. `dir' is never modified.
* *
*/ */
mystrcpy(s,dir); mystrcpy(s,dir);
root=skip_root(s);
// Test for and use the GetDiskFreeSpaceEx API // Test for and use the GetDiskFreeSpaceEx API
{ {
@ -1019,7 +1019,8 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
ULARGE_INTEGER available64; ULARGE_INTEGER available64;
ULARGE_INTEGER a, b; ULARGE_INTEGER a, b;
char *p; char *p;
for (p = s; root != p; p = trimslashtoend(s)) WORD *pw = NULL;
while ((char *) pw != s) // trimslashtoend() cut the entire string
{ {
if (GDFSE(s, &available64, &a, &b)) if (GDFSE(s, &available64, &a, &b))
{ {
@ -1032,18 +1033,13 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
if (!root) if (pw)
{ // if pw was set, remove the backslash so trimslashtoend() will cut a new one
// don't call trimslashtoend() which will destroy the string *pw = 0;
break;
}
if (s[0] == '\0') p = trimslashtoend(s); // trim last backslash
{ pw = (LPWORD) (p - 1);
// trimslashtoend() was called one too many time for some reason *pw = CHAR2_TO_WORD('\\', 0); // bring it back, but make the next char null
// bail out instead of looping infinitely...
break;
}
} }
} }
} }
@ -1051,8 +1047,11 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (!available_set) if (!available_set)
{ {
DWORD spc, bps, fc, tc; DWORD spc, bps, fc, tc;
char *root;
// GetDiskFreeSpaceEx accepts any path, but GetDiskFreeSpace accepts only the root // GetDiskFreeSpaceEx accepts any path, but GetDiskFreeSpace accepts only the root
mystrcpy(s,dir);
root=skip_root(s);
if (root) if (root)
*root=0; *root=0;