Jump to content




Compress/Extract- Convert Directories to Files


  • This topic is locked This topic is locked
6 replies to this topic

#1 nitrogenfingers

    Lua Professor

  • Members
  • 551 posts
  • LocationAustralia

Posted 03 January 2013 - 08:44 PM

I'm at a point with some of my programs where I have to upload 5 or 6 or more files to pastebin for them all to work together cohesively. This gets boring fast, so I wrote this app for larger projects to be easily send up and down again.

The compressor essentially takes and recursively parses through a directory, putting the contents of each file inside into a much larger text file. The process is then reversed by the extractor, preserving every file and the directory structure within.

It has a few problems. Firstly it doesn't decrease the file size at all, in fact it's quite a bit larger. I'm not sure if pastebin allows upload of binary files but if it does I'll look at adding huffman coding. Secondly, I've noticed io will time out on large files if you're running on a slow computer. Beware of this, not sure of a fix.

Anyway you can get it here:

Extractor: http://pastebin.com/461hnYHf
Compressor: http://pastebin.com/9PcVRBy6

And here's an example of what a compressed file will look like. It's basically a set of instructions to recreate the file- if I get around to it I'll try to make the archives self-extracting:
Spoiler

Hope someone finds it useful.

NF

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 January 2013 - 10:26 PM

Good job! Was thinking if eventually tinkering with this in the future. Was not looking forward to having to work out compression and self extraction.

I'm going to keep an eye on this post, hope you get the compression part done, coz that would be awesome!

#3 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 04 January 2013 - 02:06 AM

i could make an installer for this :D so when you execute it it will be installing the files from the installer file

#4 Mendax

  • Members
  • 366 posts

Posted 04 January 2013 - 03:57 PM

Perfect! Just what I needed for SKS-OS! (Around 20 files now...)

#5 kornichen

  • Members
  • 220 posts
  • LocationGermany

Posted 05 January 2013 - 12:18 AM

Can I use it for KREOS? (45 files at the moment :D)?

#6 nitrogenfingers

    Lua Professor

  • Members
  • 551 posts
  • LocationAustralia

Posted 05 January 2013 - 12:50 AM

I should make this more official, but really if I've put a program on the forums you can use it for about whatever- but let me see what you've done with it, if you'd be so kind :D

#7 billysback

  • Members
  • 569 posts

Posted 05 January 2013 - 12:57 AM

Nitro, for the fix on making it not bug out on large files you must make it sleep every now and again on the file writing - or reading - loop, making it sleep every time is unnecessary so add in some type of tick, the amount of times it must tick before you sleep depends on how much you are doing in the loop, in my experience it crashes at between 500 and 700 lines when almost only writing files.

look at this if you want:
Spoiler






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users