mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-06 11:18:44 +02:00
* fix ExtractFileDrive for \\server\share\path\file: it should return \\server\share
* made test easier to debug git-svn-id: trunk@13392 -
This commit is contained in:
parent
6da1d7d417
commit
6dfd5cb5b8
@ -65,14 +65,12 @@ begin
|
||||
end;
|
||||
|
||||
function ExtractFileDrive(const FileName: string): string;
|
||||
|
||||
var
|
||||
i,l: longint;
|
||||
|
||||
begin
|
||||
Result := '';
|
||||
l:=Length(FileName);
|
||||
if (L<2) then
|
||||
if (l<2) then
|
||||
exit;
|
||||
If (FileName[2] in AllowDriveSeparators) then
|
||||
result:=Copy(FileName,1,2)
|
||||
@ -80,7 +78,13 @@ begin
|
||||
(FileName[2] in AllowDirectorySeparators) then
|
||||
begin
|
||||
i := 2;
|
||||
While (i<L) and Not (Filename[i+1] in AllowDirectorySeparators) do
|
||||
|
||||
{ skip share }
|
||||
While (i<l) and Not (Filename[i+1] in AllowDirectorySeparators) do
|
||||
inc(i);
|
||||
inc(i);
|
||||
|
||||
While (i<l) and Not (Filename[i+1] in AllowDirectorySeparators) do
|
||||
inc(i);
|
||||
Result:=Copy(FileName,1,i);
|
||||
end;
|
||||
|
@ -114,15 +114,34 @@ begin
|
||||
[strPath, ExcludeTrailingPathDelimiter(strPath)]));
|
||||
|
||||
if (Format('ExtractFilePath on ''%s'' = ''%s''',[strPath, ExtractFilePath(strPath)]) <> results[1]) then
|
||||
halt(1);
|
||||
begin
|
||||
writeln('ExtractFilePath: ',ExtractFilePath(strPath));
|
||||
halt(1);
|
||||
end;
|
||||
|
||||
if (Format('ExtractFileName on ''%s'' = ''%s''',[strPath, ExtractFileName(strPath)]) <> results[2]) then
|
||||
halt(2);
|
||||
begin
|
||||
writeln('ExtractFileName: ',ExtractFileName(strPath));
|
||||
halt(2);
|
||||
end;
|
||||
|
||||
if (Format('ExtractFileDrive on ''%s'' = ''%s''',[strPath, ExtractFileDrive(strPath)]) <> results[3]) then
|
||||
halt(3);
|
||||
begin
|
||||
writeln('ExtractFileDrive: ',ExtractFileDrive(strPath));
|
||||
halt(3);
|
||||
end;
|
||||
|
||||
if (Format('IncludeTrailingPathDelimiter on ''%s'' = ''%s''',[strPath, IncludeTrailingPathDelimiter(strPath)]) <> results[4]) then
|
||||
halt(4);
|
||||
begin
|
||||
writeln('IncludeTrailingPathDelimiter: ',IncludeTrailingPathDelimiter(strPath));
|
||||
halt(4);
|
||||
end;
|
||||
|
||||
if (Format('ExcludeTrailingPathDelimiter on ''%s'' = ''%s''',[strPath, ExcludeTrailingPathDelimiter(strPath)]) <> results[5]) then
|
||||
halt(5);
|
||||
begin
|
||||
writeln('ExcludeTrailingPathDelimiter: ',ExcludeTrailingPathDelimiter(strPath));
|
||||
halt(5);
|
||||
end;
|
||||
|
||||
WriteLn;
|
||||
end;
|
||||
@ -138,4 +157,5 @@ begin
|
||||
TestFuncs('./\',results[3]);
|
||||
TestFuncs('./c:',results[4]);
|
||||
TestFuncs('\\server\share\file',results[5]);
|
||||
writeln('ok');
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user