Jump to content




Package Api

api

3 replies to this topic

#1 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 26 August 2013 - 03:09 PM

Hello everyone.
This is a little api I wrote that lets you save a directory to a single file. It's like a zip/rar/whatever file, but without compression (for now), so in most cases the file will be larger than the directory.
The package is a binary file, so you can include any binary files and they should pack/unpack correctly.

I wrote it while working on something bigger, but I thought that someone might find this usefull (probably not, but whatever :P).
So, here it is:

Download:
pastebin get gx10mzbk

Functions:
package.pack(path, outPath) -- pack directory "path" to file "outPath"
--[[
Packs a directory
Parameters:
  - path: the path to the directory to pack
  - outPath: the path to save the package file
Return Values:
  - result: boolean indicating if the operation was successful
  - error: error message in case of error
--]]

package.load(path)
--[[
Loads a package file
Parameters:
  - path: the path to the package file
Return Values:
  - entries: table containing the package entries. nil in case of error
  - error: error message in case of error
--]]

package.unpack(path, outPath)
--[[
Unpacks a package file
Parameters:
  - path: the path to the package file
  - outPath: the path to save the directory
Return Values:
  - result: boolean indicating if the operation was successful
  - error: error message in case of error
--]]

Examples:
Pack:
Spoiler
Unpack:
Spoiler

Any feedback and bug reports are welcome.

#2 Mitchfizz05

  • Members
  • 125 posts
  • LocationAdelaide, Australia

Posted 27 August 2013 - 08:20 AM

This is quite fancy!
I recommend that you make a packaging program (like the one in the example) and release it in the programs section.

#3 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 27 August 2013 - 09:40 AM

View Postmitchfizz05, on 27 August 2013 - 08:20 AM, said:

This is quite fancy!
I recommend that you make a packaging program (like the one in the example) and release it in the programs section.
Thanks.
I want to add some sort of compression before. Otherwise, there's not much use for this.

#4 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 27 August 2013 - 01:15 PM

This is useful, because I like APIs, and this one is good :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users