tim@cmu-cs-k.ARPA (Tim Maroney) (01/13/85)
Some weeks ago, I snarfed the public domain screen editor from SIMTEL20. It was nicely done, but a three-mode editor was totally unacceptable to my emacs-configured fingers. I've hacked away at it heavily, adding many features and completely replacing the user interface with an emacs-like one (although it is not emacs-like otherwise -- no multiple windows, no extension language, no marking yet). The major extension that still needs to be done is extending it to arbitrary file sizes. I have worked out a scheme for doing this, but I was wondering whether anyone else has already done it, with the new buffer module being in the public domain. If so, it would sure save a lot of time. If not, then I have a question for you CP/M wizards. Is there any portable way to make a file shrink? That is, to free sectors from the end of it that were formerly in use? If so, how? I have not examined the CP/M file system heavily, although I have hacked other parts of BIOS, so if there is a way it shouldn't be over my head. I need this because I don't want my temporary files to be stuck at their maximum length. -=- Tim Maroney, Carnegie-Mellon University Computation Center ARPA: Tim.Maroney@CMU-CS-K uucp: seismo!cmu-cs-k!tim CompuServe: 74176,1360 audio: shout "Hey, Tim!" "Remember all ye that existence is pure joy; that all the sorrows are but as shadows; they pass & are done; but there is that which remains." Liber AL, II:9.
grayson@uiucuxc.UUCP (01/16/85)
Probably the only way is to write zeroes into the directory entries ( and then reset the disk system ). But this involves knowing how those allocation block numbers are stored in the directory entries, and this is really a mess. The allocation block numbers can be either 1 or 2 bytes in length (you can figure it out), so there may be either 8 or 16 of them per directory entry. Even worse, it may happen that there is not a one-to-one correspondence between directory entries and extents. A directory entry that addresses two extents is possible, and then the extent number on the first directory entry of the file will be 0 or 1, depending on whether the file extends into the second extent. The reason for this is that the field which indicates the number of 128 byte records in the extent is just 1 byte long, with maximum allowable value of 128. Thus 16K is the maximum extent size. It's probably posssible to write the code to shrink the file portably, but only if you have access to some of these other types of CP/M systems for debugging.