Jump to content




FLCF - Fast Lightweight Compressed File


  • You cannot reply to this topic
3 replies to this topic

#1 Cross_Sans

  • Members
  • 122 posts
  • LocationFrance

Posted 25 January 2017 - 03:05 PM

FLCF - Fast Lightweight Compressed File


Hello !

Today, I created a lightweight API called FLCF which will helps you to compress files.

Download it here:
http://pastebin.com/2rYQaQef
or with the CraftOS shell:
pastebin get 2rYQaQef FLCF

It's really simple to use it:

os.loadAPI("FLCF"); -- Loads our API
FLCF.createArchive("/myArchive.flcf"); -- Create the archive at the root directory.
uarch = FLCF.openArchive("/myArchive.flcf"); -- Opens the archive newly created.
uarch.addFile("/rom/programs/edit", "/edit"); -- Adds the file edit from /rom/programs to the root directory of the archive.
uarch.saveArchive(); -- Save our edited archive.
uarch.extractFile("/edit", "/a_editor"); -- Extracts the file edit from the root directory of the archive.
uarch.removeFile("/edit"); -- Removes the file edit from the root directory of the archive.
uarch.saveArchive(); -- Save our edited archive.


That is it. Note that if you want to add multiple files from a directory, use this code:
os.loadAPI("FLCF");
FLCF.createArchive("/myArchive.flcf");
uarch = FLCF.openArchive("/myArchive.flcf");

for _, file in ipairs(fs.list("/photos")) do
if fs.isDir("/photos/" .. file) then
uarch.addFile("/photos" .. file, file);
end
end

uarch.saveArchive();

License:
Because of a outdated project stolen by Anonymous (click there to see the topic) without any permission (and also my fault because I did not put a license), this API is under MIT license (click here for license details). You can freely edit, modify, share with your friends this program; but do not forget to take credit to me if you are going to use this in a program or a operating system.

Thanks for reading my little post. I hope that you will find it useful. Please take some time to write your impressions and what needs to be added.

Have a nice day, Redall.

Edited by Redall, 25 January 2017 - 03:10 PM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 January 2017 - 01:05 AM

Er um I don't see the part where it compresses anything?

#3 Anavrins

  • Members
  • 775 posts

Posted 27 January 2017 - 02:13 AM

View PostBomb Bloke, on 27 January 2017 - 01:05 AM, said:

Er um I don't see the part where it compresses anything?
My thoughts exactly.
It looks more like something similar to a .tar file type of archiving, but there's also the fact you use the original serialize function which adds a lot of unnecessary newline and spaces, that will infact make the file much bigger than it should be, quite the opposite of compression.
Otherwise, the API looks neat and easy to use :)

Edited by Anavrins, 27 January 2017 - 02:14 AM.


#4 Cross_Sans

  • Members
  • 122 posts
  • LocationFrance

Posted 27 January 2017 - 11:21 AM

View PostBomb Bloke, on 27 January 2017 - 01:05 AM, said:

Er um I don't see the part where it compresses anything?

Yes, it not compress the data, but the files into a single file. But I plan to compress data when more people will be interested in this. And yes, I use textutils.serialise, but I will change that soon too. I was bored, so I created this API.

Edited by Redall, 27 January 2017 - 11:24 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users