Namespaces
Variants

std::experimental::filesystem:: copy_options

From cppreference.net
헤더 파일에 정의됨 <experimental/filesystem>
enum class copy_options {

none = 0 ,
skip_existing = 1 ,
overwrite_existing = 2 ,
update_existing = 4 ,
recursive = 8 ,
copy_symlinks = 16 ,
skip_symlinks = 32 ,
directories_only = 64 ,
create_symlinks = 128 ,
create_hard_links = 256

} ;
(filesystem TS)

이 타입은 copy() 함수와 copy_file() 함수의 동작을 제어하는 사용 가능한 옵션들을 나타냅니다.

copy_options BitmaskType 요구 사항을 충족합니다 (이는 비트 연산자 operator & , operator | , operator ^ , operator~ , operator & = , operator | = , 그리고 operator ^ = 가 이 타입에 대해 정의됨을 의미합니다).

멤버 상수

다음 옵션 그룹 각각에서 최대 하나의 복사 옵션이 존재할 수 있으며, 그렇지 않을 경우 복사 함수들의 동작은 정의되지 않습니다.

멤버 상수 의미
파일이 이미 존재할 때 copy_file() 동작을 제어하는 옵션
none 0 오류를 보고합니다(기본 동작).
skip_existing 1 기존 파일을 유지하고 오류를 보고하지 않습니다.
overwrite_existing 2 기존 파일을 교체합니다.
update_existing 4 기존 파일이 복사되는 파일보다 오래된 경우에만 교체합니다.
copy() 함수의 하위 디렉터리 처리 방식을 제어하는 옵션
none 0 하위 디렉터리를 건너뜁니다(기본 동작).
recursive 8 하위 디렉터리와 그 내용을 재귀적으로 복사합니다.
copy() 함수의 심볼릭 링크 처리 방식을 제어하는 옵션
none 0 심볼릭 링크를 따릅니다(기본 동작).
copy_symlinks 16 심볼릭 링크가 가리키는 파일 대신 심볼릭 링크 자체를 복사합니다.
skip_symlinks 32 심볼릭 링크를 무시합니다.
copy() 함수의 복사 유형을 제어하는 옵션
none 0 파일 내용을 복사합니다(기본 동작).
directories_only 64 디렉터리 구조만 복사하고 비디렉터리 파일은 복사하지 않습니다.
create_symlinks 128 파일 사본을 생성하는 대신 원본 파일을 가리키는 심볼릭 링크를 생성합니다. 참고: 대상 경로가 현재 디렉터리에 있지 않는 한 소스 경로는 절대 경로여야 합니다.
create_hard_links 256 파일 사본을 생성하는 대신 원본 파일과 동일한 파일을 가리키는 하드 링크를 생성합니다.

예제

#include <experimental/filesystem>
#include <fstream>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
    fs::create_directories("sandbox/dir/subdir");
    std::ofstream("sandbox/file1.txt").put('a');
    fs::copy("sandbox/file1.txt", "sandbox/file2.txt"); // 파일 복사
    fs::copy("sandbox/dir", "sandbox/dir2"); // 디렉토리 복사 (비재귀적)
    // sandbox에는 2개의 파일과 2개의 디렉토리가 있으며, 그중 하나는 하위 디렉토리를 가짐
    // sandbox/file1.txt
    // sandbox/file2.txt
    // sandbox/dir2
    // sandbox/dir
    //    sandbox/dir/subdir
    fs::copy("sandbox", "sandbox/copy", fs::copy_options::recursive);
    // sandbox/copy에는 위의 파일들과 하위 디렉토리들의 복사본이 포함됨
    fs::remove_all("sandbox");
}

참고 항목

파일 또는 디렉토리 복사
(function)
파일 내용 복사
(function)