The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,513 other followers

Archive for April 7th, 2021

Small batch file to recursively compact a directory using NTFS compression

Posted by jpluimers on 2021/04/07

compact-directory-recursively.bat:

if [%1]==[] goto :eof
call compact /s /c %1 %1\*.*

Example usage:

compact-directory-recursively.bat C:\ProgramData\{51D553F1-B483-41C2-B35E-6D461D9E0F9C}

compact-directory-recursively.bat "C:\ProgramData\Package Cache"

@for /d %d in (*.*) do @call compact-directory-recursively.bat "%d"

The @ signs are to get less output clutter.

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

Maintaining timestamps for future dates when you know the associated location

Posted by jpluimers on 2021/04/07

For past timestamps (or date-times), as long as you know the associated location, you always know the time zone rule that applies, no matter if you store them in UTC or local time zone.

For future dates, UTC might not be the best option, as you have no knowledge on future time zone rules. There you need to have at least three fields:

  • timestamp
  • time zone delta
  • time zone
  • time zone rules version

Timezone needs to be either in UTC or local time zone; the time zone delta then needs to be applied to either go to local time zone or UTC.

Both John Skeet (Twitter/github/site) and Lau Taarnskov (Twitter/github/site) both wrote great articles explaining this in much greater detail:

The time zone rules version points to the version of the TimeZone database to apply.

Information on the TimeZone database (also known as tzdb, tzdata, the zoneinfo database or IANA time zone database, and Olson database):

–jeroen

Posted in Algorithms, Development, Software Development | Leave a Comment »

ReturnAddressUnit to provide ReturnAddress to Delphi versions not supporting it, and prevent CallerAddr warnings for Delphi versions having ReturnAddress. See https://bitbucket.org/jeroenp/wiert.me/src/8ae6cf29ffc601fde7c1182dead740adddb13fb8/Native/Delphi/Library/RTL/ReturnAddressUnit.pas

Posted by jpluimers on 2021/04/07

From a check-in a while ago, when some Delphi versions complained about CallerAddr having been replaced by ReturnAddress and other versions not understanding ReturnAddress, but having CallerAddr.

The code in the [WayBack] gist and on [WayBack] BitBucket:

ReturnAddressUnit to provide ReturnAddress to Delphi versions not supporting it, and prevent CallerAddr warnings for Delphi versions having ReturnAddress. See https://bitbucket.org/jeroenp/wiert.me/src/…/Native/Delphi/Library/RTL/ReturnAddressUnit.pas

Basically the code maps a variable having a variable ReturnAddress that is a function reference returning a pointer to a function and redirects to CallerAddr when there is no ReturnAddress available. This is the case for anything below Delphi XE2, and avoids W1000 Symbol 'CallerAddr' is deprecated: 'Use ReturnAddress' for Delphi XE2 and up

It is an extract from [WayBack] dunit-extension/TestCaseExtension.pas at master · fabriciocolombo/dunit-extension · GitHub.

There is more interesting code in [WayBack] GitHub – fabriciocolombo/dunit-extension: Extended DUnit TestCase provides assertions to the types Date, Enumerator, Double, and other types, and a class to help run tests with output as XML, text and GUI mode and even more in [WayBack] fabriciocolombo (Fabricio Colombo) · GitHub , which are on my list of things to play with in the future.

Some more [WayBack] commits are at [WayBack] GitHub – cesarliws/dunit-extension (more on [WayBack] Cesar Romero tomorrow).

I think the code from Fabricio is inspired by [WayBack] ZeosLib/TestFrameWork.pas at master · svn2github/ZeosLib · GitHub as it uses the same HAS_BUILTIN_RETURNADDRESS define.

The code by Fabricio is smarter though.

Via: “Delphi” “CallerAddr” “ReturnAddress” – Google Search

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, DUnit, Software Development | Leave a Comment »

 
%d bloggers like this: