Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ucla-cs!zen!ucbvax!COGSCI.BERKELEY.EDU!bryce From: bryce@COGSCI.BERKELEY.EDU (Bryce Nesbitt) Newsgroups: comp.sys.amiga Subject: Re: chdir() problem. Message-ID: <8707311234.AA24254@cogsci.berkeley.edu> Date: Fri, 31-Jul-87 08:34:51 EDT Article-I.D.: cogsci.8707311234.AA24254 Posted: Fri Jul 31 08:34:51 1987 Date-Received: Sat, 1-Aug-87 21:42:16 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: Institute of Cognitive Studies, UC Berkeley Lines: 45 Summary: You are *still* leaking a lock. In article <> jrh4373@tamvenus Joel << Hatchet >> Hall typed: > > 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 must first assume that when you say "unlock" you really meant "UnLock". The functions with the capitalization are direct DOS calls. Where you say "chdir" you should really be using "CurrentDir". Now here's the fun part: It returns a lock. When you chdir'ed into the temp directory something opened a lock on it (what havoc if some processes's current directory was to be deleted!!!). Now that you are backing out, you need to free that lock. In general it is unwise to mix direct DOS calls and C language calls with wild abandon. Unless you are clairvoyant, use one *or* the other. 1/2 :-) If you check free memory before and after running your program you will find that you are loosing memory. Probably the amount that a FileLock takes! Count all your locks, use only one class of calls, examine function returns for locks, and check for memory loss. Hope it helps! ----- |\ /| . Ack! (NAK, EOT, SOH) {o O} . ( " ) bryce@cogsci.berkeley.EDU -or- ucbvax!cogsci!bryce U "Aparantly, Uncle Sam is Ma Bell's wife."