Recent

Author Topic: compact files  (Read 2272 times)

fabiopesaju

  • Jr. Member
  • **
  • Posts: 96
compact files
« on: December 28, 2018, 06:01:42 pm »
hello...

please, about compaction, which component can you suggest me? (for pure text files)

Bart

  • Hero Member
  • *****
  • Posts: 5575
    • Bart en Mariska's Webstek
Re: compact files
« Reply #1 on: December 28, 2018, 06:29:21 pm »
Zip?
Fc has libs for it.

Bart

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: compact files
« Reply #2 on: December 28, 2018, 06:45:38 pm »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

wp

  • Hero Member
  • *****
  • Posts: 12908
Re: compact files
« Reply #3 on: December 28, 2018, 07:00:22 pm »

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: compact files
« Reply #4 on: December 29, 2018, 07:54:01 am »
I always considered the stream approach best:
https://www.freepascal.org/docs-html/fcl/zstream/index.html

Some code example:
https://github.com/Zaflis/nxpascal/blob/master/src/nxData.pas

The principle of the class was to keep a whole gameworld loaded in memory at the time. But only the active areas are decompressed. I have tested that working on a realtime game, compressing and decompressing tile chunks with threading as camera moves rapidly. It actually was far smoother with threads, the app doesn't lock up waiting for the compression. Even a few milliseconds may be noticeable.

You can compress/decompress a TStringList when using:
https://www.freepascal.org/docs-html/rtl/classes/tstrings.loadfromstream.html
But you might need TMemoryStream and/or TFileStream in the process. But it's far better than needing to save uncompressed file to disk, and then load it back in for zipping and resaving. Depends on what you intended to do...
« Last Edit: December 29, 2018, 11:22:42 am by User137 »

 

TinyPortal © 2005-2018