[comp.sys.amiga] AmigaDos DeleteFile

JRH4373@TAMVENUS.BITNET (07/30/87)

[Go ahead...eat my line!]
Reposted from JRH4373@TAMVENUS.BITNET
     
In a previous posting I typed the following:
>Time for another question.  I am experiencing a bit of difficulty with the
>AmigaD*S function DeleteFile().  The documentation I have states that this
>function will delete a file or directory.  The problem is, in an application
>I am writing, I am getting an object in use error when trying to delete any
>directory after having deleted all files in that directory.  The files all
>delete fine, but when an attempt is then made to delete the directory, I get
>the error.  Keep in mind that this is a directory that my program has recently
>created using mkdir() and no other processes are active.  Upon exiting the
>program, the del command will not delete it either although I can cd to it.
>Only by rebooting the system will the harddisk mount clean up the directory
>to allow it to be deleted.  I am sure I must be missing some trivial tidbit
>of knowledge concerning deleting files, but I have looked till I am blue in
>the face and have failed to find anything that solves this problem.
>Anyone out there have any idea what I am doing wrong?
     
A lot of you have responded to try UnLock.  I neglected to mention that I
had already tried this.  The exact sequence is this:
 0.  starting in the directory 'original_dir'
 1.  lock = CreateDir("temp")
 2.  unlock(lock)
 3.  chdir("temp")
 4.  lock = CreateDir("temp")
 5.  unlock(lock)
 6.  chdir("temp")
 7.  So now I am in 'original_dir/temp/temp'
 8.  chdir("original_dir/temp") /* go back to first created directory */
 9.  DeleteFile("temp")  /* This works fine */
10.  chdir("original_dir") /* I am now back at the original directory */
11.  DeleteFile("temp") /* This DOES NOT WORK!  Object in use error */
     
I have since tried relocking and then unlocking the directory immediately
before deleteing the directories.  Same result.
     
BTW, the AmigaD*S manual is rather vague about the name of the
lock structure.  In the RKM, in dosextens.h, I found a FileLock
structure and a comment indicating that this is what Lock(), etc
return.  Why then, does lattice issue a 'pointers to different objects'
warning when I declare a variable lock as 'struct FileLock *' and then
use it like this:  'lock = CreateDir()'?  Is FileLock the right name?
Do I have to declare CreatDir() as an extern and specify it's type or what?
     
     


I would like to thank those who have responded so far.  It helps to know
someone is willing to help.
******************************************************************************
Joel << Hatchet >> Hall
jrh4373@tamvenus
I think therefore I am...an Amiga user.
Disclaimer:  I would disclaim my existance, but if I didn't exist, I wouldn't
need to disclaim anything.  So if I don't disclaim something, does that mean I
don't exist...