summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6356457)
raw | patch | inline | side by side (parent: 6356457)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 21 Oct 2019 03:23:58 +0000 (06:23 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 21 Oct 2019 03:25:37 +0000 (06:25 +0300) |
src/shared/utils.pas | patch | blob | history |
diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 0ac5caa00f15004d8f7901fa99eadf36f966712c..bf8abf4fbc98a8d0ce8de1b687e6b35da9d63cd7 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
// rewrites slashes to '/'
function fixSlashes (s: AnsiString): AnsiString;
+function isAbsolutePath (const s: AnsiString): Boolean;
+function isRootPath (const s: AnsiString): Boolean;
+
// strips out name from `fn`, leaving trailing slash
function getFilenamePath (const fn: AnsiString): AnsiString;
end;
+function isAbsolutePath (const s: AnsiString): Boolean;
+begin
+ result := false;
+ if (length(s) = 0) then exit;
+ {$IFDEF WINDOWS}
+ if (s[1] = '/') or (s[1] = '\') then begin result := true; exit; end;
+ if (length(s) > 2) and (s[2] = ':') and ((s[3] = '/') or (s[3] = '\')) then begin result := true; exit; end;
+ {$ELSE}
+ result := (s[1] = '/');
+ {$ENDIF}
+end;
+
+
+function isRootPath (const s: AnsiString): Boolean;
+begin
+ result := false;
+ if (length(s) = 0) then exit;
+ {$IFDEF WINDOWS}
+ if (s = '/') or (s = '\') then begin result := true; exit; end;
+ if (length(s) = 3) and (s[2] = ':') and ((s[3] = '/') or (s[3] = '\')) then begin result := true; exit; end;
+ {$ELSE}
+ result := (s = '/');
+ {$ENDIF}
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
constructor TSimpleList.TEnumerator.Create (const aitems: TItemArr; acount: Integer);
begin