The Common File System supports four share modes for opening files. The constants used to specify these modes appear in the following table. These constants are defined in the CfsConstants pool dictionary.
Like file locking types, share modes are not uniformly supported by all platforms. Some platforms can have default share modes that are associated with access modes, and cannot be changed. For example, opening a file with ORDONLY access might have the same effect as specifying the ODENYWR share mode, and opening a file with OWRONLY access might have the same effect as specifying ODENYRDWR. On platforms that do not support specifiable share modes, share modes are ignored.To determine whether a particular share mode is supported, send the supportsShareMode: message to the CfsFileDescriptor class, with the desired share mode constant as an argument. If the specified share mode is supported, true is answered. Otherwise, false is answered. The following code fragment determines if the ODENYRDWR share mode is supported:To open a file descriptor with a specific share mode, send the open:oflag:share: message to the CfsFileDescriptor class instead of sending open:oflag:. The third argument specifies the share mode to use. If share modes are not supported, it has no effect. Here are some examples:
![]() |