unit uEtcetra_PS_HTTPClient;
{< for Etcetra functions, methods, classes}

interface

uses
  System.SysUtils, System.Classes;

type
  TEtcetra = class(TDataModule)
  private


    { Private declarations }
  public

   class function GetFileSize(AFilePath: String): Int64;

   class function Translit(s: string): string; static;

  end;

//var
//  Etcetra: TEtcetra;

implementation

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}


{ TEtcetra }

class function TEtcetra.GetFileSize(AFilePath: String): Int64;
var
  FS: TFileStream;


begin


  try

     Result:=-1;

     FS := TFileStream.Create(AFilePath, fmOpenRead);

      try
        Result:=FS.Size;
      finally
        FS.Free;
      end;

  except

         on E:EStreamError do

         begin

         Result := -1;

          raise Exception.Create('This is EStreamError EClassName'+E.ClassName+' '
          +'EMessage '+E.Message);

         end;


  on E:Exception do

        begin
           Result := -1;




           raise Exception.Create(E.ClassName+' Exception Raised : '
         +#13#10+#13#10+E.Message);

        end;

  end;

end;


class function TEtcetra.Translit(s: string): string;
const
rus: string = 'àáâãäå¸æçèéêëìíîïðñòóôõö÷øùüûúýþÿ ';
lat: array[1..34] of string = ('a', 'b', 'v', 'g', 'd', 'e', 'yo', 'zh', 'z', 'i', 'y', 'k',
'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'ts', 'ch', 'sh', 'shch',
'''', 'y', '''', 'e', 'yu', 'ya','-');
var
p, i, l: integer;
begin
s:=widelowercase(s);
Result := '';
l := Length(s);
for i := 1 to l do
begin
p := Pos(s[i], rus);
if p<1 then Result := Result + s[i] else Result := Result + lat[p];


end;
end;


end.
