An user interface set for my UNDELETE... please contribute

Eric Auer <[email protected]> Fri, 1 Nov 2002 23:25:26 +0100 (MET)
Newsgroups gmane.os.freedos.devel
Message-ID <[email protected]>
Hi, I have some plans for an user interface.
Please tell me what you think and if some of the needed software thingies
are already there.

First thing that I would need:
chkname foo bar * .txt
Will construct a filename consisting of "foo" + "bar" + "??" + ".txt" that
does not yet exist in the current directory, and save that name to %NAME%.

Next, I need versions of pushd and popd that do not only change the
directory but also the drive. Excuse me if pushd and popd can already do this.

Next, I need "global". I have a freeware version, but a version that is GNU
would be better. It simply changes to every subdirectory of the current
directory and executes its argument (command) there.

Finally, I need something that stores the current working directory and drive
in, for example, %PWD%.


This will all be used to write 3 batch files (the last one maybe has to be
written in a more powerful language - how about Perl 4 from the SimTel GNUish
tools???

File one: MIRROR
Use:      MIRROR x: y:\z\ foo.zip (the foo.zip argument is optional)
Effect:
x:
pushd
ccd y:\z\ (also changing to y: here)
chkname Y root * .bin
popd
undelete syssave root %NAME%
"swapd" (like cd - in Unix)
chkname Y boot * .bin
"swapd"
undelete syssave boot %NAME%
"swapd"
chkname Y fat1 * .bin
"swapd"
undelete syssave fat1 %NAME%
"swapd"
chkname Y fat2 * .bin
"swapd"
undelete syssave fat2 %NAME%
"swapd"
if argument 3 given, zip -m %argument3% *.bin

Non-technically: The root directory, boot sector and both fats will be
written to y:\z\ into files named yroot??.bin, yboot??.bin ... and then
be moved to a zip file. I assume that CHKNAME includes the current drive
and working directory into %NAME%, otherwise I would have to run the
"PWD setting tool" and use %PWD%%NAME% instead.

I think this should come with an example:
1st example, circular:
mirror c: d:\ %DATE%.zip
mirror d: e:\ %DATE%.zip
mirror e: c:\ %DATE%.zip
If mirror is a .bat file, it must be:
call mirror c: d:\ d:\%DATE%.zip
call ...
call ...

2nd example:
well, you guess it. Mirror all drives, use a ramdisk for the .bin files
and pack everything into A:\mirr-all.zip




File two: TREESAVE
Use:      TREESAVE x:\y\ a:\b\c.zip (the "zip" argument is optional)
Effect:
do globally {
   "pwdtool"
   pushd
   cdd x:\y\
   chkname A dir * .bin
   popd
   %BINNAME% = %NAME%
} ... sorry, wrong, again ...

do globally {
   "pwdtool" (sets %PWDIR% and %PWDISK%)
   pushd
   cdd x:\y\
   chkname A dir * .bin
   %BINNAME% = x:\y\%NAME%
   chkname A dir * .txt
   popd
   (alternatively: "%PWDISK%" and then "cd %PWDIR%", or: "cdd %PWDISK%%PWDIR%")
   undelete dirsave %PWDIR% %BINNAME% x:\y\%NAME%
}
zip -m a:\b\c.zip x:\y\?dir*.txt x:\y\?dir*.bin (only if "zip" argument set)

Non-technically: For every directory, the current directory gets saved to
Adir????.bin (binary) and Adir????.txt (user-readable), ???? being a number
chosen so that every directory ends up in its own file (should probably log
which directory is stored where...!). Note that "A" (and "Y" above) is the
%PWDISK% drive letter (sigh... so %PWDISK% should be available with and with-
out ":"? I really get annoyed by the poor string handling functionality of the
DOS shells!). And that x:\y\ is the 1st argument and a:\b\c.zip the 2nd
argument to the TREESAVE file. In short, treesave will save all directories
from the current directory on (all child directories and the directory itself,
that is) into a bunch of files. For the paranoid guys that do not think that
MIRROR would be enough!




File three: UNERASE
Use:        UNERASE foo*.do? x:\y\
Effect:
Will use undelete dirsave [current directory] x:\y\unerase.bin > x:\y\unerase.log
(x:\y\ being from the 2nd argument), then use %PAGER% (e.g. LESS from GNUish
-> dos-only tools) to display unerase.log (because of human intelligence, you
know... and because of long filename fragments that are not processed but
displayed yet). It will then select all entries of undeleteable files in the
directory that match the pattern, in our example they could be called
?oot.doc and ?oobar.dot, and display them to the user, one at a time. The user
then has to provide the 1st character (which gets lost during deletion) or
presse escape (to skip the file), and the file will be written to, in our
example, x:\y\foot.doc or x:\y\goobar.dot ... I think this may require far more
string processing than a .BAT file is able to do :-(.

Non-technically: All deleted files matching the argument 1 pattern will be
rescued/extracted to files in directory/drive "argument 2".




Especially for the third tool, I would be happy if somebody else could do it.
The other tools are much easier (given the four helper tools, which I would
need, too!) to be implemented as .BAT files. But they are far less useful for
"everyday havoc". UNERASE is the tool that the non-professional user would
have wanted instead of my UNDELETE...

Any feedback and contributions welcome, both for the 2+1 files and the 4 helper
tools.

Eric

PS: For the professional user, here "how to undelete c:\foo\bar.txt in a
nutshell"...
c:
undelete dirsave \foo d:\undeldir.bin > d:\undeldir.log
less d:\undeldir.log
rem the user finds an "undelable" entry "?ar.txt" which starts at
rem cluster 42 and is 10 clusters long... has to calc bytes to clusters here
undelete follow 42 d:\bar.txt 10