TFile.Size

I use very often the System.IOUtils units with the wonderful classes/records TPath, TDirectory and TFile. They are much more comfortable than the old functions from System.SysUtils like FindFirst etc..

But there is one method I’m really missing: It is the size of a file. For sure there are some workarounds but I think that this method belongs to TFile. That’s why I wrote a small helper class:

type
  TFileHelper = record helper for TFile
  public
    class function Size(const APath: string): Int64; static;
  end;

{ TFileHelper }

class function TFileHelper.Size(const APath: string): Int64;
var
  pStream: TFileStream;
begin
  pStream := OpenRead(APath);
  try
    Result := pStream.Size;
  finally
    pStream.Free;
  end;
end;

I will try to convince Marco or Jim to add this method to the next release. So stay tuned.

Posted in C++-Builder, Delphi, RAD Studio 10.2 Tokyo, Uncategorized | Comments Off on TFile.Size

RAD Studio 10.2 Tokyo and TurboPack

Maybe most of you already heard that the next release of RAD Studio will be 10.2 Tokyo. Additionally to supporting Win32, Win64, MacOS, iOS and Android RAD Studio 10.2 Tokyo will support Linux64.

As always  I updated the TurboPack libraries and made them available via GetIt and hosted them under GitHub.

But this time we changed the location to a Tokyo-specific one. The reason is that it is easier to find the fitting version for your version of RAD Studio.

For RAD Studio 10.2 Tokyo I updated the suffix of the packages from ‘240’ to ‘250’. The ‘240’ 10.1 Berlin versions for RAD Studio XE are still available under GitHub.

The libraries compile for Delphi and C++Builder.

Maybe the most important change is that compression toolkit Abbrevia also works for Linux64.

Currently they libraries are:

  1. Abbrevia
  2. AsyncPro
  3. DOS command
  4. Essentials
  5. LockBox
  6. LockBox 3
  7. OnGuard FMX
  8. OnGuard VCL
  9. Orpheus
  10. PNG components
  11. PowerPDF
  12. SynEdit
  13. SysTools
  14. VirtualTreeView
Posted in C++-Builder, Delphi, FireMonkey, RAD Studio 10 Seattle, RAD Studio 10.1 Berlin, RAD Studio 10.2 Tokyo, RAD Studio XE5, RAD Studio XE6, RAD Studio XE7, RAD Studio XE8, SourceForge, Third Party Components, Tips and Tricks, TurboPack, TurboPower | Comments Off on RAD Studio 10.2 Tokyo and TurboPack

IMAPSize

From time to time I’m making backups from my IMAP account. Therefore I’m using a small tool called IMAPSize.

IMAPSize is written in Delphi 5 and the code is hosted under sourceforge.

Last week it has been impossible to connect to my IMAP account with IMAPSize that’s why I wanted to debug it.

Since I didn’t want to reinstall Delphi 5 I converted the code to Delphi Berlin and published it under bitbucket.

I had to get rid of some very old Third Party VCL components and replaced them with the VCL standard controls so that the Delphi Berlin version currently isn’t as smooth as the original one. But with some additional hours of time things could be fixed.

Anyway, I could debug the tool and found out what the problem was: IMAPSize uses the Synapse components to connect to an IMAP server which themselves use OpenSSL. Therefore IMAPSize ships two dlls which were simply outdated.

Now I’m considering to move IMAPSize to FireMonkey and additionally to a console application. With these changes IMAPSize would run on the Mac and maybe in the future on Linux but I therefore I would need some sponsors. So any help or thoughts are appreciated.

Posted in Delphi, RAD Studio 10.1 Berlin, SourceForge, Third Party Components, Tips and Tricks, TurboPack | Comments Off on IMAPSize

EncodeString

This week I had to migrate an application from Delphi XE3 to Delphi Berlin and this application uses a Base64 encoding.

Normally Base64 encoding is not difficult stuff and Delphi XE3 simply offers the function EncodeString in the unit Soap.EncdDecd.

Since Delphi Berlin has the same function I thought that I didn’t have to change a single line of code. But the first thing I realized is that the function is nearly deprecated. This means that it already has a deprecated comment: // deprecated ‘Use TNetEncoding.Base64.Encode’.

Such a comment means that the function will become deprecated with one of the next Delphi releases.

A short look at the implementation shows the reason:

function EncodeString(const Input: string): string;
begin
  Result := TNetEncoding.Base64.Encode(Input);
end;

I should call TNetEncoding.Base64.Encode directly instead of using the old function EncodeString.

But then I realized that the two Delphi versions show different results.

Let’s have a look at a small example with some German umlauts:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(EncodeString('ÄäÖöÜüß'));
end;

Delphi XE3 shows ‘xOTW9tz83w==’ whereas Delphi Berlin shows ‘w4TDpMOWw7bDnMO8w58=’.

So bad luck, I had to have a deeper look at the code. Let’s start with Delphi XE3:

function EncodeString(const Input: string): string;
var
  InStr, OutStr: TStringStream;
begin
  InStr := TStringStream.Create(Input);
  try
    OutStr := TStringStream.Create('');
    try
      EncodeStream(InStr, OutStr);
      Result := OutStr.DataString;
    finally
      OutStr.Free;
    end;
  finally
    InStr.Free;
  end;
end;
 ...
 constructor TStringStream.Create(const AString: string);
 begin
   Create(AString, TEncoding.Default, False);
 end;

This means that the string is first converted into bytes with the help of the default encoding which is under Windows an ANSI encoding. After that the bytes are encoded.

Let’s have a look at the Delphi Berlin implementation:

function TNetEncoding.Encode(const Input: string): string;
begin
  Result := DoEncode(Input);
end;
...
function TBase64Encoding.DoEncode(const Input: string): string;
begin
  Result := DoEncodeBytesToString(TEncoding.UTF8.GetBytes(Input));
end;

Delphi Berlin always converts the string into UTF-8 bytes and then encodes the bytes. This means that the implementation of EncodeString in Delphi Berlin differs to the implementation in XE3.

To fix this issue let’s try the following implementation in Delphi Berlin:

procedure TForm1.Button1Click(Sender: TObject);
var
  lBytes: TBytes;
begin
  lBytes := TEncoding.Default.GetBytes('ÄäÖöÜüß');
  lBytes := TNetEncoding.Base64.Encode(lBytes);
  ShowMessage(TEncoding.Default.GetString(lBytes));
end;

I first convert the string into bytes with the help of the default encoding. Then I encode the bytes with the new Base64 class and at the end I have to convert the bytes back to a string.

I will contact Embarcadero/Idera and ask them if I should write a quality portal case.

Posted in C++-Builder, Delphi, FireMonkey, RAD Studio 10 Seattle, RAD Studio 10.1 Berlin, RAD Studio XE5, RAD Studio XE6, RAD Studio XE7, RAD Studio XE8, Tips and Tricks, Uncategorized | Comments Off on EncodeString

GitHub or Bitbucket

I’m currently hosting the TurboPack components under GitHub but which not surprisingly supports Git. But normally I’m working with HG because of the great TortoiseHG tool.

With the the help of the HGGit extension I can use TortoiseHG with Git bit it doesn’t work smoothly. That’s why I’m considering to move all libraries to Bitbucket and HG.

Does anyone have any objections or reasons why I shouldn’t do so?

Posted in C++-Builder, Delphi, FireMonkey, RAD Studio 10 Seattle, RAD Studio 10.1 Berlin, RAD Studio XE5, RAD Studio XE6, RAD Studio XE7, RAD Studio XE8, SourceForge, Third Party Components, Tips and Tricks, TurboPack, TurboPower, Uncategorized | Comments Off on GitHub or Bitbucket

RAD Studio 10.1 Berlin and TurboPack

Maybe most of you already heard the latest news, today RAD Studio 10.1 Berlin shipped. With the release of the version of RAD Studio I updated the TurboPack libraries. You can download the TurboPack libraries manually from the TurboPack website or you can use the GetIt tool from RAD Studio.

For RAD Studio 10.1 I updated the suffix of the packages from ‘230’ to ‘240’. The ‘230’ 10.0 Seattle versions for RAD Studio XE are still available under GitHub.

The current libraries are:

  1. Abbrevia
  2. AsyncPro
  3. DOS command
  4. Essentials
  5. LockBox
  6. LockBox 3
  7. OnGuard FMX
  8. OnGuard VCL
  9. Orpheus
  10. PNG components
  11. PowerPDF
  12. SynEdit
  13. SysTools
  14. VirtualTreeView
Posted in C++-Builder, Delphi, FireMonkey, RAD Studio 10 Seattle, RAD Studio 10.1 Berlin, RAD Studio XE5, RAD Studio XE6, RAD Studio XE7, RAD Studio XE8, SourceForge, Third Party Components, Tips and Tricks, TurboPack, TurboPower, Uncategorized | Comments Off on RAD Studio 10.1 Berlin and TurboPack

ConTEXT Editor 2nd

Today I published the ConTEXT editor.

As I explained in my previous post ConTEXT is a small, fast and powerful freeware text editor, developed to serve as a secondary tool for software developers.

It has originally been hosted here. During the last weeks I tried to contact the original developers and even Marco Cantu from Embarcadero tried to contact someone from the original team but without success.

That’s why I published the source code under bitbucket. The code can be compiled with Delphi 10 Seattle. I also added the Win32 and Win64 binaries. For the German language I uploaded a language file.

If someone is interested it would be terrific to add further languages.

Posted in Delphi, RAD Studio 10 Seattle, RAD Studio XE6, Third Party Components, TurboPack, Uncategorized | Comments Off on ConTEXT Editor 2nd

ConTEXT Editor

For an interesting RPG II to Delphi project I needed an editor with crosslines. Since the standard commercial an open source editors don’t offer this feature I played a bit with the open source ConTEXT editor which is not maintained any longer.

The ConTEXT editor is written in Delphi so that I can add features myself. That’s why I compiled the source code with Delphi 10 Seattle, removed some bugs and now have a working version.

Since the editor is open source I would like to send the modified source code back to the original maintainers but they simply don’t react to my emails.

That’s why I’m asking if someone knows these guys and if yes if they are interested in maintaining the editor again? If not I’m considering to publish the code myself.

Posted in Uncategorized | Comments Off on ConTEXT Editor

VirtualTreeView and C++Builder

During the last weeks some people hat problems with the VirtualTreeView and the C++Builder. The reason was an issue with the not called initialization part. But we could find a workaround so that the current versions from JAM and TurboPack now are working properly with the C++Builder.

Posted in Uncategorized | Comments Off on VirtualTreeView and C++Builder

RAD Studio 10 Seattle and TurboPack

Maybe most of you already heard the latest news, today RAD Studio 10 Seattle shipped. With the release of the version of RAD Studio I updated the TurboPack libraries. You can download the TurboPack libraries manually from the TurboPack website or you can use the GetIt tool from RAD Studio.

For RAD Studio 10 I updated the suffix of the packages from ‘220’ to ‘230’. The ‘220’ versions for RAD Studio XE are still available under GitHub.

I also added two further libraries to TurboPack, the PNG components and the DOS command component.

With this new components the current libraries are:

  1. Abbrevia
  2. AsyncPro
  3. DOS command
  4. Essentials
  5. LockBox
  6. LockBox 3
  7. OnGuard FMX
  8. OnGuard VCL
  9. Orpheus
  10. PNG components
  11. PowerPDF
  12. SynEdit
  13. SysTools
  14. VirtualTreeView
Posted in C++-Builder, Delphi, FireMonkey, RAD Studio 10 Seattle, RAD Studio XE5, RAD Studio XE6, RAD Studio XE7, RAD Studio XE8, SourceForge, Third Party Components, Tips and Tricks, TurboPack, TurboPower, Uncategorized | Tagged | Comments Off on RAD Studio 10 Seattle and TurboPack