The initial idea started with a discussion with Stefan (Stefan Haubenthal) concerning transferring files and code over Facebook without the horrible limitations that the Facebook platform messing them up. We came to the conclusion that it would be nice to be able to encode and decode Base64 files in order to be able to post them online. Stefan created a command-line utility (util/conv/base64enc.lha) and we decided to create a Directory Opus ARexx script to facilitate encoding and decoding of files.
The current implementation is pure ARexx (without using external utilities) and is thus not as fast as it could be with the help of an external tool. On the other hand, the tradeoff is that this implementation uses constant memory consumption which means that regardless how large the files are that you wish to encode or decode, the scripts will eventually succeed without running out of memory.
There are two scripts in the package:
DOpus4-ToB64.rexx
DOpus4-FromB64.rexx
and for each of those you can create buttons or shortcuts in Directory Opus 4. The following instructions describe how to create a button for DOpus4-ToB64.rexx
but the same would apply to the other file DOpus4-FromB64. Naturally, you can also create a menu item instead so the instructions are only for creating buttons.
DOpus4-ToB64.rexx
wherever you see fit. (It is tidy, for example, to create an ARexx directory in DOPUS4: and then place your scripts there.)To B64
, for example) and create a new entry.DOpus4-ToB64.rexx
script.
You can now repeat the same procedure for the DOpus4-FromB64.rexx
script.
In DirectoryOpus 4, open up two directories in the two window panes, select some files in one window that you wish to encode and hit the To B64
button (the one corresponding to the DOpus4-ToB64.rexx
script). The script will then encode the file to Base64 and save it in the other opened window pane with the extra extension .b64
appended. To decode, you select a file with the .b64
extension, hit the From B64
button and the script decodes the file and saves the result in the opposite pane without the .b64
extension.
Note that the .b64
extension is added by the script for convenience but that you can of course decode any file encoded in Base64 even if it does not have the .b64
extension.
If you like to tweak, then you can open each of these scripts and toy with the chunk size parameter in the configuration section at the top. The chunk size represents how much is read from the input file at a time and must be a multiple of 4 for the DOpus4-FromB64.rexx
script, respectively a multiple of 6 for the DOpus4-ToB64.rexx
script. Each of these chunks will be read into memory such that increasing the chunk size too much may lead to memory starvation. On the other hand, depending on your machine, reading larger chunks may speed-up the script. The defaults should be universally safe for all machines.
The script uses a custom-implementation of some functions which can all be found on the ARexx FUSS page.