@@ -5,13 +5,17 @@ Functions for unzipping files. (Future may include zipping as well.)
55
66Dependencies:
77
8- - MacOS users must have `unzip` and `gunzip`, but these are usually installed with the OS.
8+ - The Windows version uses `PowerShell`.
9+ - The macOS version uses `unzip` and `gunzip`.
10+ - In both cases the necessary tools are pre-installed with a typical installation of any version
11+ of the OS that supports 64-bit Finale.
912
1013Pay careful attention to the comments about how strings are encoded. They are either encoded
1114**platform** or **utf8**. On macOS, platform encoding is always utf8, but on Windows it can
1215be any number of encodings depending on the locale settings and version of Windows. You can use
13- `luaosutils.text` to convert them back and forth. Both `luaosutils.process.execute`
14- requires platform encoding as do `lfs` and all built-in Lua `io` functions.
16+ `luaosutils.text` to convert them back and forth. (Use the `get_default_codepage` function to get
17+ the platform encoding.) The `luaosutils.process.execute` function requires platform encoding as do
18+ `lfs` and all built-in Lua `os` and `io` functions that take strings as input.
1519
1620Note that many functions require later versions of RGP Lua that include `luaosutils`
1721and/or `lfs`. But the these dependencies are embedded in each function so that any version
@@ -74,7 +78,6 @@ Returns a path that can be used as a temporary target for unzipping. The caller
7478either as a file or a directory, because it is guaranteed not to exist when it is returned and it does
7579not have a terminating path delimiter. Also returns a platform-dependent unzip command that can be
7680passed to `luaosutils.process.execute` to unzip the input archive into the temporary name as a directory.
77- The command may not be compatible with `os.execute`.
7881
7982This function requires `luaosutils`.
8083
116119--[[
117120% calc_gunzip_command
118121
119- Returns the platform-dependent command to gunzip a file. It can be passed
122+ Returns the platform-dependent command to gunzip a file to `stdout` . It can be passed
120123to `luaosutils.process.execute`, which will then return the text directly.
121124
122-
123125@ archive_path (string) platform-encoded path of source gzip archive.
124126: (string) platform-encoded command string to execute.
125127]]
142144--[[
143145% calc_is_gzip
144146
145- Detects if an input buffer is a gzip archive. Sometimes, Finale gzips the internal EnigmaXML document.
147+ Detects if an input buffer is a gzip archive.
146148
147149@ buffer (string) binary data to check if it is a gzip archive
148150: (boolean) true if the buffer is a gzip archive
@@ -199,6 +201,11 @@ function ziputils.extract_enigmaxml(filepath)
199201 error (filepath .. " is not a .musx file." , 2 )
200202 end
201203
204+ -- Steps to extract:
205+ -- Unzip the `.musx` (which is `.zip` in disguise)
206+ -- Run the `score.dat` file through `crypt_enigmaxml_buffer` to get a gzip archive of the EnigmaXML file.
207+ -- Gunzip the extracted EnigmaXML gzip archive into a string and return it.
208+
202209 local text = require (" luaosutils" ).text
203210 local process = require (" luaosutils" ).process
204211
0 commit comments