• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: When is a file open but not open?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: When is a file open but not open?


  • Subject: RE: When is a file open but not open?
  • From: Emmanuel <email@hidden>
  • Date: Fri, 5 Aug 2005 19:42:03 +0200

At 12:08 PM -0400 8/5/05, Grimm, Kenneth wrote:
So when would I use just "write" in place of the "open for
access/write/close for access" dance?

Note that when you just "write" you write to the beginning of the file, but you do not shorten the file: if you write "R" to a file which stores "Bush" you get "Rush".


Is one safer? Provides file locking? All my books suggest the dance, not
just the "write"... can you explain further why one and not the other, or do
both have their place in certain instances?

There are two instances that I know where you want to open the file with write permission before writing.


1 - you need sequential access: for instance, you want to write several things one after the other:

write "hello"
write " "
write "world"

If you do that the file being not open, as I told above you write and rewrite the beginning of the file only.

2 - you need to be sure that no-one is also writing to the file: open with write permission does lock the file - actually I think it's the OS' genuine mechanism to lock whatever resource might be accessed by several clients.

Emmanuel
_______________________________________________
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


  • Follow-Ups:
    • Re: When is a file open but not open?
      • From: deivy petrescu <email@hidden>
References: 
 >RE: When is a file open but not open? (From: "Grimm, Kenneth" <email@hidden>)

  • Prev by Date: RE: When is a file open but not open?
  • Next by Date: Strange error...
  • Previous by thread: RE: When is a file open but not open?
  • Next by thread: Re: When is a file open but not open?
  • Index(es):
    • Date
    • Thread