Changeset 230 for Common/UURI.pas


Ignore:
Timestamp:
Apr 14, 2011, 12:45:52 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Třída UThreading zajišťující udržování seznamu alokovaných vláken.
  • Upraveno: Třída TURI nyní využívá vlastní konstantu DirSeparator.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UURI.pas

    r226 r230  
    99uses
    1010  Classes, SysUtils;
     11
     12const
     13  URIPathSeparator = '/';
    1114
    1215type
     
    2124    Items: TStringList;
    2225    IsAbsolute: Boolean;
     26    DirSeparator: string;
    2327    procedure Assign(Source: TPath);
    2428    constructor Create;
     
    137141  I: Integer;
    138142begin
    139   if IsAbsolute then Result := DirectorySeparator
     143  if IsAbsolute then Result := DirSeparator
    140144    else Result := '';
    141145  for I := 0 to Items.Count - 1 do
    142     Result := Result + Items[I] + DirectorySeparator;
     146    Result := Result + Items[I] + DirSeparator;
    143147end;
    144148
     
    149153  Items.Clear;
    150154  if Length(AValue) > 0 then begin
    151     if AValue[1] = DirectorySeparator then begin
     155    if AValue[1] = DirSeparator then begin
    152156      IsAbsolute := True;
    153157      Delete(AValue, 1, 1);
    154158    end else IsAbsolute := False;
    155     while Pos(DirectorySeparator, AValue) > 0 do begin
    156       Name := Copy(AValue, 1, Pos(DirectorySeparator, AValue) - 1);
    157       Delete(AValue, 1, Pos(DirectorySeparator, AValue));
     159    while Pos(DirSeparator, AValue) > 0 do begin
     160      Name := Copy(AValue, 1, Pos(DirSeparator, AValue) - 1);
     161      Delete(AValue, 1, Pos(DirSeparator, AValue));
    158162      Items.Add(Name);
    159163    end;
     
    167171  IsAbsolute := Source.IsAbsolute;
    168172  Items.Assign(Source.Items);
     173  DirSeparator := Source.DirSeparator;
    169174end;
    170175
     
    172177begin
    173178  Items := TStringList.Create;
     179  DirSeparator := DirectorySeparator;
    174180end;
    175181
     
    188194  if Path.Combine <> '' then begin
    189195    Result := Result + '//' + Authority;
    190     if Path.Drive <> '' then Result := Result + '/';
     196    if Scheme = 'file' then Result := Result + URIPathSeparator;
    191197    Result := Result + Path.Combine;
    192198  end;
    193199  if Query <> '' then Result := Result + '?' + Query;
    194200  if Fragment <> '' then Result := Result + '#' + Fragment;
    195   StringReplace(Result, '\', '/', [rfReplaceAll]);
    196201end;
    197202
     
    204209  if Copy(Value, 1, 2) = '//' then begin
    205210    Value := Copy(Value, 3, Length(Value));
    206     LeftCutString(Value, Authority, '/');
     211    LeftCutString(Value, Authority, URIPathSeparator);
    207212  end;
    208213  RightCutString(Value, Fragment, '#');
    209214  RightCutString(Value, Query, '?', '=&');
    210   if (Length(Value) > 2) and (Value[2] = DriveSeparator) then
    211     Delete(Value, 1, 1); // Remove beginning slash
     215  //if Scheme = 'file' then Delete(Value, 1, 1); // Remove beginning slash
    212216  Path.Parse(Value);
    213217end;
     
    216220begin
    217221  Path := TFileName.Create;
     222  Path.Directory.DirSeparator := URIPathSeparator;
    218223end;
    219224
     
    278283  end else LeftCutString(Value, HostAddr, '', '.');
    279284  Host := HostAddr;
    280   LeftCutString(Value, TempPath, '', '/.');
     285  LeftCutString(Value, TempPath, '', URIPathSeparator + '.');
    281286  Path.Parse(TempPath);
    282287end;
     
    311316    Extension := ExtensionSeparator + Extension;
    312317  end else Extension := '';
    313   if Pos(DirectorySeparator, AValue) > 0 then RightCutString(AValue, Name, DirectorySeparator)
     318  if Pos(Directory.DirSeparator, AValue) > 0 then
     319    RightCutString(AValue, Name, Directory.DirSeparator)
    314320    else begin
    315321      Name := AValue;
Note: See TracChangeset for help on using the changeset viewer.