LazFileUtils: Split some implementations into Windows and Unix specific include files.

git-svn-id: trunk@41451 -
This commit is contained in:
bart 2013-05-29 13:05:12 +00:00
parent 9b22e58354
commit 47f5c33813
3 changed files with 61 additions and 57 deletions

View File

@ -1002,63 +1002,6 @@ begin
end;
end;
function IsUNCPath(const Path: String): Boolean;
begin
{$IFDEF Windows}
Result := (Length(Path) > 2) and (Path[1] = PathDelim) and (Path[2] = PathDelim);
{$ELSE}
Result := false;
{$ENDIF}
end;
function ExtractUNCVolume(const Path: String): String;
{$IFDEF Windows}
var
I, Len: Integer;
// the next function reuses Len variable
function NextPathDelim(const Start: Integer): Integer;// inline;
begin
Result := Start;
while (Result <= Len) and (Path[Result] <> PathDelim) do
inc(Result);
end;
begin
if not IsUNCPath(Path) then
Exit('');
I := 3;
Len := Length(Path);
if Path[I] = '?' then
begin
// Long UNC path form like:
// \\?\UNC\ComputerName\SharedFolder\Resource or
// \\?\C:\Directory
inc(I);
if Path[I] <> PathDelim then
Exit('');
if UpperCase(Copy(Path, I + 1, 3)) = 'UNC' then
begin
inc(I, 4);
if I < Len then
I := NextPathDelim(I + 1);
if I < Len then
I := NextPathDelim(I + 1);
end;
end
else
begin
I := NextPathDelim(I);
if I < Len then
I := NextPathDelim(I + 1);
end;
Result := Copy(Path, 1, I);
end;
{$ELSE}
begin
Result := '';
end;
{$ENDIF}
{
Returns

View File

@ -265,6 +265,18 @@ begin
end;
function IsUNCPath(const Path: String): Boolean;
begin
Result := false;
end;
function ExtractUNCVolume(const Path: String): String;
begin
Result := '';
end;
procedure InitLazFileUtils;
begin
//dummy

View File

@ -797,6 +797,55 @@ begin
end;
function IsUNCPath(const Path: String): Boolean;
begin
Result := (Length(Path) > 2) and (Path[1] = PathDelim) and (Path[2] = PathDelim);
end;
function ExtractUNCVolume(const Path: String): String;
var
I, Len: Integer;
// the next function reuses Len variable
function NextPathDelim(const Start: Integer): Integer;// inline;
begin
Result := Start;
while (Result <= Len) and (Path[Result] <> PathDelim) do
inc(Result);
end;
begin
if not IsUNCPath(Path) then
Exit('');
I := 3;
Len := Length(Path);
if Path[I] = '?' then
begin
// Long UNC path form like:
// \\?\UNC\ComputerName\SharedFolder\Resource or
// \\?\C:\Directory
inc(I);
if Path[I] <> PathDelim then
Exit('');
if UpperCase(Copy(Path, I + 1, 3)) = 'UNC' then
begin
inc(I, 4);
if I < Len then
I := NextPathDelim(I + 1);
if I < Len then
I := NextPathDelim(I + 1);
end;
end
else
begin
I := NextPathDelim(I);
if I < Len then
I := NextPathDelim(I + 1);
end;
Result := Copy(Path, 1, I);
end;
procedure InitLazFileUtils;