파일 시스템 라이브러리
cppreference.com
< cpp
파일 시스템 라이브러리는 경로, 일반 파일, 디렉터리 같은 파일 시스템의 구성요소를 다루는 기능을 제공합니다.
원래 boost.filesystem에서 개발되었고, ISO/IEC TS 18822:2015 기술규약문서로 제출되어, C++17의 ISO C++ 표준에 포함되었습니다. 부스트 구현체는 표준 C++17 라이브러리보다 더 많은 기능을 제공하며, 지원하는 컴파일러의 수도 더 많습니다.
계층적 파일 시스템에 접근할 수 없거나, 필요한 기능을 제공하지 않는 경우 파일시스템 라이브러리가 제공하는 기능을 이용하지 못할 수도 있습니다. 일부 기능은 기반 파일 시스템에서 지원하지 않기 때문에 사용할 수 없는 경우도 있습니다. 예컨데 FAT 파일 시스템에는 심볼링 링크 기능이나 하드링크 기능이 빠져 있습니다. 이런 경우 오류는 반드시 보고 되어야 합니다.
파일 시스템 내의 동일 객체에 대해 다중 쓰레드, 다중 프로세스 등의 교차 접근 및 수정이 발생할 경우 파일 시스템 경쟁(file system race)이 발생할 수 있는데, 이때 라이브러리에서 제공하는 함수를 호출하면 어떻게 동작할지는 undefined 입니다.
목차 |
[편집] 라이브러리에서 사용하는 용어 정의
- 파일(file): 데이터를 저장하고 있는 파일 시스템 객체. 읽고, 쓸 수 있다. 파일은 이름, 속성, 그리고 아래 파일 형식 중 하나를 가진다.:
- 디렉터리(directory): 디렉터리 항목들을 담고 있는 컨테이너 개념의 파일. 다른 파일들(일부는 디렉터리, 중첩 디렉터리)을 구별한다. 특정 파일을 이야기 할 때 디렉터리는 그 파일의 부모 디렉터리 형태로 표현된다. 부모 디렉터리는 상대 경로명 ".." 으로 표시할 수 있다.
- 하드 링크(hard link): 기존 파일에 연결된 디렉터리 항목. 다중 ���드 링크가 지원되면, 원본에 대한 하드 링크가 모두 지워져야지만 원본 파일이 삭제된다.
- 심볼릭 링크(symbolic link): 경로에 대해 연결된 디렉터리 항목. 그 경로가 존재하지 않을 수도 있다.
- 일반 파일(regular file): 위 파일 타입에 속하지 않는 파일.
- 파일명: 파일을 가리키는 문자열. 기반 파일 시스템에 따라 허용되는 문자, 대소문자 구별, 최대 길이, 사용할 수 없는 이름 등의 구현방식이 달라진다.라이브러리에서 "." (점)과 ".." (점-점)은 특별한 의미를 가진다.
- path: sequence of elements that identifies a file. It begins with an optional root-name (e.g. "C:" or "//server" on Windows), followed by an optional root-directory (e.g. "/" on Unix), followed by a sequence of zero or more file names (all but last of which have to be directories or links to directories). The native format (e.g. which characters are used as separators) and character encoding of the string representation of a path (the pathname) is implementation-defined, this library provides portable representation of paths.
- absolute path: a path that unambiguously identifies the location of a file.
- canonical path: an absolute path that includes no symlinks, "." or ".." elements.
- relative path: a path that identifies the location of a file relative to some location on the file system. The special path names "." (dot, "current directory") and ".." (dot-dot, "parent directory") are relative paths.
[편집] 클래스
틀:cpp/filesystem/dsc directory entry틀:cpp/filesystem/dsc directory iterator틀:cpp/filesystem/dsc recursive directory iterator틀:cpp/filesystem/dsc file status틀:cpp/filesystem/dsc space info틀:cpp/filesystem/dsc file type틀:cpp/filesystem/dsc perms틀:cpp/filesystem/dsc perm options틀:cpp/filesystem/dsc copy options틀:cpp/filesystem/dsc directory options틀:cpp/filesystem/dsc file time type <filesystem> 헤더에 정의됨. | |
Defined in namespace
filesystem | |
(C++17) |
경로를 표현하는 클래스 (class) |
(C++17) |
파일 시스템 오류에 대한 예외 (class) |
[편집] 비-멤버 함수
틀:cpp/filesystem/dsc canonical틀:cpp/filesystem/dsc relative틀:cpp/filesystem/dsc copy틀:cpp/filesystem/dsc copy file틀:cpp/filesystem/dsc copy symlink틀:cpp/filesystem/dsc create directory틀:cpp/filesystem/dsc create hard link틀:cpp/filesystem/dsc create symlink틀:cpp/filesystem/dsc current path틀:cpp/filesystem/dsc exists틀:cpp/filesystem/dsc equivalent틀:cpp/filesystem/dsc file size틀:cpp/filesystem/dsc hard link count틀:cpp/filesystem/dsc last write time틀:cpp/filesystem/dsc permissions틀:cpp/filesystem/dsc read symlink틀:cpp/filesystem/dsc remove틀:cpp/filesystem/dsc rename틀:cpp/filesystem/dsc resize file틀:cpp/filesystem/dsc space틀:cpp/filesystem/dsc status틀:cpp/filesystem/dsc temp directory path틀:cpp/filesystem/dsc is block file틀:cpp/filesystem/dsc is character file틀:cpp/filesystem/dsc is directory틀:cpp/filesystem/dsc is empty틀:cpp/filesystem/dsc is fifo틀:cpp/filesystem/dsc is other틀:cpp/filesystem/dsc is regular file틀:cpp/filesystem/dsc is socket틀:cpp/filesystem/dsc is symlink틀:cpp/filesystem/dsc status known (C++17) |
composes an absolute path (function) |
File types |
[편집] Notes
이 라이브러리를 사용하려면 컴파일러 버전에 따라 추가 컴파일러/링커 옵션이 필요한 경우도 있습니다. GNU 구현체 9.1 이전 버전에서는 -lstdc++fs 옵션을, LLVM 9.0 이전 버전에서는 -lc++fs 옵션을 사용해야 합니다.
[편집] See also
C++ documentation for File System TS
|