diff options
-rw-r--r-- | src/corelib/gfxbase.pas | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 6fdc14a0..63004a1f 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -2081,10 +2081,18 @@ procedure TfpgFileListBase.PopulateSpecialDirs(const aDirectory: TfpgString); var i, n, sp: integer; begin - // find insert position + // FSpecialDirs under Windows will be all available drive letters. + // FSpecialDirs under Linux is the root (/) + + // find insert position in FSpecialDirs where we can insert all parts + // of aDirectory. i := 0; + // We have to user UpperCase() because under Windows aDirectory's drive + // letter could be lower case, but Win API returns initial drive letters + // in upper case, so the second test could never be false causing + // Index out of bounds error further down. while (i < FSpecialDirs.Count) - and (FSpecialDirs.Strings[i][1] < aDirectory[1]) do + and (UpperCase(FSpecialDirs.Strings[i][1]) < UpperCase(aDirectory[1])) do Inc(i); sp := Pos(DirectorySeparator, aDirectory) + 1; |