Skip to content

Modern Fs PreservePermissions

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Filesystem › Filesystem Library › CopyOptions.PreservePermissions

CopyOptions.PreservePermissions

Chooses whether CopyDir keeps permission bits or attributes; false by default.

Syntax

CopyOptions.PreservePermissions

Examples

#import "std/fs"
using fs

'' Everything below happens inside a temp directory of its own, and is
'' removed at the end
dim td as FsResultUStr = CreateTempDir( "fbdoc" )
dim as ustring dir_ = td.Value( )

'' A field of CopyOptions, DEFAULT FALSE
CreateDir( PathJoin( dir_, "src" ) )
WriteAllText( PathJoin( dir_, "src", "f.txt" ), "x" )

dim opts as CopyOptions
print opts.PreservePermissions           '' false

opts.PreservePermissions = true
print CopyDir( PathJoin( dir_, "src" ), PathJoin( dir_, "dst" ), opts ).IsOk( )

'' It is SetPosixMode on POSIX and the attribute word on Windows -- the
'' same operation on each platform's OWN model, not a translation
'' between them. There is no portable mode to translate.

RemoveDirAll( dir_ )

Library: Filesystem Library
Category: Filesystem
Documented under: File Operations

Clone this wiki locally