Skip to content

Ability to open local files through non-physical paths [CORE3160] #3536

Open
@firebird-automations

Description

@firebird-automations

Submitted by: nandod (nandod)

Firebird on Windows can't open local database files through non-physical paths, such as those created by the ancient but still supported SUBST utility:

SUBST S: C:\DB

I have been putting filters in my applications that silently convert the path to a physical one (a simple matter of calling QueryDosDevice()), but it would be good if Firebird supported this out-of-the-box.

For completeness, here's the code I use (Delphi):

function MakePhysicalPath(const APath: string): string;
var
LDriveLetter: string;
LNewPath: string;
begin
LDriveLetter := ExtractFileDrive(APath);

SetLength\(LNewPath, MAX\_PATH \+ 1\);
SetLength\(LNewPath, QueryDosDevice\(PChar\(LDriveLetter\), PChar\(LNewPath\), Length\(LNewPath\)\)\);
if Pos\('\\??\\', LNewPath\) = 1 then
  LNewPath := StrPas\(@LNewPath\[5\]\)
else
  LNewPath := '';

if LNewPath = '' then
  Result := APath
else
  Result := LNewPath \+ Copy\(APath, 3, MaxInt\);

end;