[comp.lang.c] Nulling out the filename in Turbo C 1.5

rcr@picuxa.UUCP (Richard Court ) (04/23/88)

I am writing a program to remove all traces of a file from a disk.  Everything
is in place except for the following:

I would like to null out the entire filename from the FAT instead of just the
first character.  Can anyone give me any insights as to how to go about doing
this?

I thank anyone in advance who can set me off in the write direction.

dhesi@bsu-cs.UUCP (Rahul Dhesi) (04/24/88)

In article <554@picuxa.UUCP> rcr@picuxa.UUCP (Richard Court ) writes:
>I would like to null out the entire filename from the FAT instead of just the
>first character.

I suspect you will get lots of replies telling you how to access the
file allocation table directly.

Don't.  Too many programmers hastily do low-level nonportable stuff,
and aren't around a year or two later when the software breaks and the
frustrated user has to switch to a new product.

I suggest the following portable approach.

Reserve a funny single-character filename for your own use.  Suppose it
is "@".  To remove the filename of your target file from the file
allocation table, you:

(a) delete any file called "@" if it exists
(b) rename the file you are zapping to "@"
(c) delete the new file "@"

MS-DOS system calls exist to delete and rename files.  Please
double-check to make sure that the above does completely eradicate the
filename from disk.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi