Moving and copying file system instances

TFileSystemCopier and TFileSystemMover handle all copy and operations that involve the physical entities of the file system.

TFileSystemCopier copies entities between directories on the same or different volumes. Copy allows you to rename either the entities being copied or those that exist at the target. TFileSystemMover moves entities between directories on the same volume. To move entities between different volumes, you need to copy the entities using TFileSystemCopier, then explicitly delete the source entities.

You construct TFileSystemCopier and TFileSystemMover using the empty constructor. The TFileSystemCopier constructor provides an optional parameter that specifies whether it stops or continues if an error occurs during copying. The default behavior of the TFileSystemCopier empty constructor is to stop copying.

To copy entities, you call TFileSystemCopier::Copy. To move one or more entities, you call TFileSystemMover::Move. Both the Copy and the Move member functions take the same parameters:

When you specify a directory as a source entity, the Copy or Move member function operates on the entire sub-tree rooted at that directory. These member functions require read access on each file that they move or copy.

TFileSystemCopier::Copy stops by default on failure; however, it can be set to throw an exception only after it attempts to complete the entire copy operation. For example, if Copy tries to copy a directory and its contents to another location, and it cannot copy one file because it does not have proper access, the member function finishes copying all remaining files and directories before throwing the exception.

If you pass TFileSystemMover::Move a source entity and a destination entity that inhabit different volumes, Move throws an exception. Move, unlike Copy, is always handled as a single operation for all files and directories.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker