From 47f5c33813169c8f7e43d7a63d40ddc0867323c2 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Wed, 29 May 2013 13:05:12 +0000 Subject: [PATCH] LazFileUtils: Split some implementations into Windows and Unix specific include files. git-svn-id: trunk@41451 - --- components/lazutils/lazfileutils.pas | 57 ------------------------ components/lazutils/unixlazfileutils.inc | 12 +++++ components/lazutils/winlazfileutils.inc | 49 ++++++++++++++++++++ 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/components/lazutils/lazfileutils.pas b/components/lazutils/lazfileutils.pas index 56bc2e9188..917c91b522 100644 --- a/components/lazutils/lazfileutils.pas +++ b/components/lazutils/lazfileutils.pas @@ -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 diff --git a/components/lazutils/unixlazfileutils.inc b/components/lazutils/unixlazfileutils.inc index 37f3df4cd5..067127c17d 100644 --- a/components/lazutils/unixlazfileutils.inc +++ b/components/lazutils/unixlazfileutils.inc @@ -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 diff --git a/components/lazutils/winlazfileutils.inc b/components/lazutils/winlazfileutils.inc index 277c31be82..cf29e0f1cc 100644 --- a/components/lazutils/winlazfileutils.inc +++ b/components/lazutils/winlazfileutils.inc @@ -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;