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)
{
static char s[NSIS_MAX_STRLEN];
char *root;
int error = 0;
int available_set = 0;
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).
* 3. `s' stays valid after the loop for GetDiskFreeSpace.
* 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.
* 5. `dir' is never modified.
* 5. Both functions require a trailing backslash
* 6. `dir' is never modified.
*
*/
mystrcpy(s,dir);
root=skip_root(s);
// 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 a, b;
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))
{
@ -1032,18 +1033,13 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
break;
}
if (!root)
{
// don't call trimslashtoend() which will destroy the string
break;
}
if (pw)
// if pw was set, remove the backslash so trimslashtoend() will cut a new one
*pw = 0;
if (s[0] == '\0')
{
// trimslashtoend() was called one too many time for some reason
// bail out instead of looping infinitely...
break;
}
p = trimslashtoend(s); // trim last backslash
pw = (LPWORD) (p - 1);
*pw = CHAR2_TO_WORD('\\', 0); // bring it back, but make the next char null
}
}
}
@ -1051,8 +1047,11 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (!available_set)
{
DWORD spc, bps, fc, tc;
char *root;
// GetDiskFreeSpaceEx accepts any path, but GetDiskFreeSpace accepts only the root
mystrcpy(s,dir);
root=skip_root(s);
if (root)
*root=0;