[Coco] No easy rename on OS-9 ?
Gene Heskett
gheskett at wdtv.com
Wed Mar 26 17:09:03 EDT 2014
On Wednesday 26 March 2014 16:30:52 Luis Antoniosi (CoCoDemus) did opine:
> I'm very disappointed to discover that there ain't no I$Rename on
> OS-9. This is the reason the file becomes empty on cp/m wordstar save.
> As it tries to rename the scratch file and doesn't find it, it makes a
> new one. I was ignoring the BDOS rename call.
>
> The rename.asm from os-9 repo is pretty large. I can make a smaller
> copy/delete but this is not the optimal solution and could run out of
> space.
>
> As far I understood the rename.asm, it opens a directory raw file and
> change the name on it ? Is that correct ? Is it safe with multi
> threading doing this way ? What could be the other solution ? Using
> fork to create a rename process ?
I think so. One could fork the rename module. But I just looked at
rename.asm and while it may work, what its doing makes relatively little
sense to me.
In fact, if I find the time, I might re-write a new rename/mv utility.
Basic outline:
1. allocate 3 $20 byte buffers, and 4 256 byte buffers. that won't be all,
but the rest will be appended when the need arises.
2 strncpy old name to 256 byte buffer 1
3 strncpy new name to 256 byte buffer 2
4 save pwd
5 parse the 1st buffer to extract the ending filename
6 strncpy it to the first $20 byte buffer and the 3rd one too
7 parse the 2nd buffer to extract the ending filename
8 strncpy that to the 2nd $20 byte buffer.
9 parse the 1st 256 byte buffer to get the path to the directory
10 put that in 256 byte buffer 3
11 parse the 2nd 256 byte buffer for the path to that directory
12 save it in 256 byte buffer 4
13 set attrs for a directory and open the pathlist for 256 byte buffer 3
14 setup a read loop, using the 3rd buffer as cache to look for the name in
buffer 1, or terminate with an E$FNF if not found.
15 when the match is found, strncpy 29 bytes from buffer 2 to buffer 3.
You do not want to destroy the FD's address.
Now, if NOT doing a move, seek back $20 bytes on that path and write the
$20 bytes of buffer 3. Clean up and go home. If doing the move, null the
first byte of buffer 1 and write its $20 bytes back instead.
Now for the move. open the pathlist in the 2nd 256 byte buffer as a
directory and seek to EOF. Write the $20 bytes of buffer 3. Close both
directory files. Then, just for S&G's fork a dsort against both pathlists,
one at a time.
Clean up and go home.
Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
More information about the Coco
mailing list