What's the format of the single-file Codea project?

What do I have to do to emulate the “Send by email” facility of Codea which concatenates a project’s files into a single file? My situation is that I have the files on my computer and would like to create a “single file” version. I’d rather do it from the command line than have to go back into Codea and email it to myself.

So what’s the required formatting?

(I know I could reverse engineer the result, but there’s always the danger I’d miss something, and I think the information would be useful here.)

I recall @Bortels figured this out with his decodea tool. This is the location: http://home.bortels.us/decodea/

The format is a bit obscure, and I don’t recall exactly what it is — we serialize a Cocoa file wrapper for the directory. It’s not a format I like very much, but it was easy to read and write.

Okay, I didn’t explain myself well (actually, I think I explained myself incorrectly - sorry). I actually meant the single file format when you Copy a project. I forgot that when I did this, I then pasted it into an email and sent it to myself (even more tortuous) and just remembered emailing it to myself.

So, what’s the format when you Copy a project to the clipboard?

Ah that’s a lot easier.

--# TabName1
<Your TabName1 contents>

--# TabName2
<Your TabName2 contentx>


--# TabNameN
<Your TabNameN contents>

Ordering is whatever your custom buffer order is in Codea. Codea will arrange the tabs in the order specified in the file (this also allows you to run the file as a single-tab project).

Thanks. I think I can just about cope with a script to create that from a file directory.

Yes. The .codea file format was ugly, and I never figured it out 100% - I read it was a standard RTF Folder format, but was never able to find bit of off-the-shelf software other than Codea that could consume it. While I do wish we had the functionality (and we mostly do with this single file format), the actual .codea files themselves are welcome to lie in a shallow grave.

Hmm. I should modify the decodea pages to give you the one-cut-and-paste format above, in my copious free time. Sigh.

Okay, here’s my first go:

perl -MXML::Parser -e '
$p = XML::Parser->new(Style => "Tree");
$t = $p->parsefile("Info.plist");
$i = 4;
while () {
push (@files, $t->[1][4][16][$i][2]);
$i += 4;
if (ref($t->[1][4][16][$i]) ne 'ARRAY') {
$nfiles = @files;
for ($i = 0; $i < $nfiles; $i++) {
print "\
--# $files[$i]\
open(FILE, $files[$i] . ".lua");
while(<FILE> ) {
}; print "\

Obviously it’s highly sensitive to the structure of Info.plist and the magic numbers should be dynamically decided.

For those who didn’t get @Andrew_Stacey’s joke: he started writing this script some time after 8:51PM this evening, not 20 days ago. :slight_smile: