LTjake has asked for the wisdom of the Perl Monks concerning the following question:

In my ongoing quest to party like it's 1994, I've been writing a module to implement SAUCE. It's basically a method to write metadata to the end a file. It was used primarily in the "art scene" (ansi, ascii, whatever).

Reading in records has been no problem - writing them , however, has brought forward an issue.

In the "SAUCE IN FILES" section of the above documentation, they describe the file structure as so: Thus, when writing the information a the file, is it not true that one must explicitly write an EOF marker? I've been told that the character in question in chr(26). Is this true for only the Windows/DOS environment, or is there a way to write the EOF marker on any platform?

Also, wouldn't this method of writing metadata corrupt files for programs that ignore said EOF marker?

Replies are listed 'Best First'.
Re: Metadata and the EOF marker
by Abigail-II (Bishop) on Sep 04, 2002 at 16:30 UTC
    Unix does not have a physical EOF marker. The inode stores the size of the file, so no EOF is needed. Of course, you could make up an EOF marker, but the SAUCE spec state the EOF marker is needed for other programs, so that isn't going to work. It's a trick that only is going to work on platforms that have the concept of an EOF marker.

    It's not at all portable.

    Abigail

Re: Metadata and the EOF marker
by Zaxo (Archbishop) on Sep 04, 2002 at 17:05 UTC

    I'm sure that chr(26) as a marker is what is called for. A file format can be parsed on any os, so the standard should be followed.

    Interestingly, perl follows the same convention. A perl script can include metadata following a ^D or ^Z (chr(4) or chr(26)) which marks the end of the script. Nobody uses that much, because __DATA__ and __END__ do the same thing much more printably, hence readably. See perldata for details.

    After Compline,
    Zaxo

      I'm sure that chr(26) as a marker is what is called for. A file format can be parsed on any os, so the standard should be followed.

      I do agree with this statement but if you take a look at the specification to which LTjake linked, it makes the claim, "In reality, we'll be adding SAUCE to every file you can imagine."

      As it requires the SAUCE data to come after the chr(26), presumably it is trying to succeed in its claim by hiding itself after the normal end of file. So, for instance, you might dump some SAUCE at the end of some config file you have without every worrying that the program is going to mistakenly read your SAUCE as part of the configuration. That breaks on Unix. I think that's what Abigail meant by saying it wasn't portable.

      -sauoq
      "My two cents aren't worth a dime.";
      
Re: Metadata and the EOF marker
by Aristotle (Chancellor) on Sep 05, 2002 at 04:31 UTC
    It only works on platforms where the OS differentiates between text and binary files, where input from text files is cooked by the OS before the program sees it. It follows then that it won't work on platforms that don't have this distinction (just about any modern OS besides the Windows derivatives doesn't), or with programs that explicitly request uncooked input from the OS.

    Makeshifts last the longest.