Re: When is a file open but not open?
Re: When is a file open but not open?
- Subject: Re: When is a file open but not open?
- From: "Gary (Lists)" <email@hidden>
- Date: Fri, 05 Aug 2005 10:32:51 -0400
> On Aug 4, 2005, at 16:28, John Jones wrote:
>
>> Thanks Paul,
>>
>> It's not permission problem in the file or directory, the script
>> routinely writes to that directory or other files in that
>> directory. There's something going on somewhere else with a
>> specific file. If I move the file to the trash the system won't
>> let me delete it because it thinks the file is busy.
>>
>> John
Sometimes an app just can't let go. This is (was) common with IE when that
was my primary web browser, and was more of a problem with Entourage than
now. This was particularly true for the download cache file and the cache
".lck" files.
I only point these out as examples of a file that is considered "in use" by
some now-dead process or some now-dead 'hook' to the file.
The only reliable way that I found to empty the trash or dispose of the file
was to restart. In OSX, I've sometimes been able to just kill the process
or log out to regain access to the file, but a full restart is sometimes
needed.
I have not had any problems (that I did not specifically cause) using 'open
for access'. The main problem that I cause myself there is usually in
testing, when I am running lines of script line-by-line. If I forget to
close, then I'm usually stuck. Once the testing is done, however, the state
of the file is generally quite knowable and those kinds of errors are able
to be avoided.
(Zip disks, particularly, would give me those "-110" (?) errors when they
started to wear out, and the disk could not be put away (ejected), or it
would start an eject-insert cycle that was maddening.)
"deivy petrescu" wrote:
> John,
> I've tried as much as I could to avoid using "open for access".
> It always ends up causing problems.
> Somethings you can do to avoid the problem:
> a. close access to the file before you open.
> b. when you close a file, do it twice.
>
> Now, the best thing to avoid any problems is to avoid it altogether.
> And, you can avoid it.
> You can simply write to a file without opening it.
> This is the script:
> <script>
> set pd to path to desktop as Unicode text
> set pd to ("" & pd & "testanu123.txt")
> tell application "Finder"
> try
> close access alias pd
> end try
> set j to open for access alias pd with write permission
> close access j
> end tell
> write ("This is a test" & return) to file pd
>
> write ("This is another test" & return) to file pd starting at eof
> </script>
Deivy, I don't understand. You said "without opening it", but you use 'open
for access'. Am I missing something clever? Or do you mean that you just
open then immediately close the file, in order to gain a usable reference
for 'write'?
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden