Thread Safety

A surrogate instance (a file system entity) is only a handle to a physical entity. Multiple file system entities can point to a single physical entity.

The classes that comprise the File System interface are not multithread-safe. You cannot share individual file system entity instances. Even though the entity instances themselves are not thread-safe, however, the underlying physical objects they represent usually are. You can make copies of an instance and simultaneously use the original and each copy in a different thread.

Copies of file system instances are very inexpensive to construct, and the File System interface is designed to ensure that the implementation of copy semantics is efficient.

Note: If the files themselves are not thread-safe--for example, if there are two unsynchronized threads writing to a file at once--making copies of the entity instances will not help.



Introduction to the File System
Overview of File System Entities


Instantiating a File System Entity from a Host-Specific Pathname
Instantiating a File System Entity from a Portable Pathname
Instantiating a File System Entity from Another Instance of the Same Entity Class
Setting Stream Access Permissions
Accessing File Contents Using C++ Streams
Accessing File Contents Using Open Class Streams