Utils::FilePath Class
class Utils::FilePathFilePath 클래스는 (원격일 수도 있는) 파일 시스템 내 객체에 대한 핸들을 추상화한 것으로, URL이나, 로컬의 경우 파일 또는 디렉터리로의 경로와 유사합니다. 더 보기...
| Header: | #include <FilePath> |
공개 함수
| Utils::FilePath | absoluteFilePath() const |
| Utils::FilePath | absolutePath() const |
| Utils::FileStreamHandle | asyncCopy(const Utils::Continuation<> &cont, const Utils::FilePath &target) const |
| Utils::FileStreamHandle | asyncRead(const Utils::Continuation<QByteArray> &cont) const |
| Utils::FileStreamHandle | asyncWrite(const Utils::Continuation<qint64> &cont, const QByteArray &data) const |
| QString | baseName() const |
| qint64 | bytesAvailable() const |
| Utils::FilePath | canonicalPath() const |
| Utils::FilePath | chopped(int n) const |
| Utils::FilePath | cleanPath() const |
| void | clear() |
| QString | completeBaseName() const |
| QString | completeSuffix() const |
| bool | contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseInsensitive) const |
| Utils::Result<> | copyFile(const Utils::FilePath &target) const |
| Utils::Result<> | copyRecursively(const Utils::FilePath &target) const |
| bool | createDir() const |
| Utils::Result<> | createSymLink(const Utils::FilePath &symLink) const |
| Utils::Result<Utils::FilePath> | createTempDir() const |
| Utils::Result<Utils::FilePath> | createTempFile() const |
| Utils::Environment | deviceEnvironment() const |
| Utils::Result<Utils::Environment> | deviceEnvironmentWithError() const |
| Utils::FilePaths | devicePathEnvironmentVariable() const |
| Utils::FilePaths | dirEntries(QDir::Filters filters) const |
| Utils::FilePaths | dirEntries(const Utils::FileFilter &filter, QDir::SortFlags sort = QDir::NoSort) const |
| QString | displayName(const QString &args = {}) const |
| bool | endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseInsensitive) const |
| bool | ensureExistingFile() const |
| Utils::Result<> | ensureReachable(const Utils::FilePath &other) const |
| Utils::Result<> | ensureWritableDir() const |
| bool | equalsCaseSensitive(const Utils::FilePath &other) const |
| bool | exists() const |
| Utils::Result<QByteArray> | fileContents(qint64 maxSize = -1, qint64 offset = 0) const |
| QString | fileName() const |
| QStringView | fileNameView() const |
| QString | fileNameWithPathComponents(int pathComponents) const |
| qint64 | fileSize() const |
| QString | group() const |
| uint | groupId() const |
| bool | hasHardLinks() const |
| QStringView | host() const |
| Utils::FilePath | intern() const |
| bool | isAbsolutePath() const |
| bool | isChildOf(const Utils::FilePath &s) const |
| bool | isEmpty() const |
| bool | isExecutableFile() const |
| bool | isLocal() const |
| bool | isNewerThan(const QDateTime &timeStamp) const |
| bool | isRelativePath() const |
| bool | isResourceFile() const |
| bool | isRootPath() const |
| bool | isSameDevice(const Utils::FilePath &other) const |
| bool | isSameExecutable(const Utils::FilePath &other) const |
| bool | isSameFile(const Utils::FilePath &other) const |
| bool | isWritableDir() const |
| bool | isWritableFile() const |
| void | iterateDirectory(const Utils::FilePath::IterateDirCallback &callBack, const Utils::FileFilter &filter) const |
| QDateTime | lastModified() const |
| Utils::Result<Utils::FilePath> | localSource() const |
| Utils::Result<> | makeWritable() const |
| QString | nativePath() const |
| Utils::OsType | osType() const |
| QString | owner() const |
| uint | ownerId() const |
| Utils::FilePath | parentDir() const |
| QString | path() const |
| Utils::FilePath | pathAppended(const QString &path) const |
| QChar | pathComponentSeparator() const |
| QList<QStringView> | pathComponents() const |
| QChar | pathListSeparator() const |
| QStringView | pathView() const |
| QFileDevice::Permissions | permissions() const |
| std::optional<Utils::FilePath> | prefixRemoved(const QString &str) const |
| Utils::TextEncoding | processStdErrEncoding() const |
| Utils::TextEncoding | processStdOutEncoding() const |
| std::optional<Utils::FilePath> | refersToExecutableFile(Utils::FilePath::MatchScope matchScope) const |
| Utils::FilePath | relativeChildPath(const Utils::FilePath &parent) const |
| QString | relativeNativePathFromDir(const Utils::FilePath &anchorDir) const |
| QString | relativePathFromDir(const Utils::FilePath &anchorDir) const |
| Utils::Result<> | removeFile() const |
| Utils::Result<> | removeRecursively() const |
| Utils::Result<> | renameFile(const Utils::FilePath &target) const |
| Utils::FilePath | resolvePath(const QString &tail) const |
| Utils::FilePath | resolvePath(const Utils::FilePath &tail) const |
| Utils::FilePath | resolveSymlinks() const |
| QStringView | scheme() const |
| Utils::FilePaths | searchAllInDirectories(const Utils::FilePaths &dirs, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const |
| Utils::FilePaths | searchAllInPath() const |
| Utils::FilePaths | searchAllInPath(const Utils::FilePaths &additionalDirs, Utils::FilePath::PathAmending amending = AppendToPath, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const |
| void | searchHereAndInParents(const std::function<IterationPolicy (const FilePath &)> &constraint) const |
| Utils::FilePath | searchHereAndInParents(const QString &fileName, QDir::Filter type) const |
| Utils::FilePath | searchHereAndInParents(const QStringList &fileNames, QDir::Filter type) const |
| Utils::FilePath | searchInDirectories(const Utils::FilePaths &dirs, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const |
| Utils::FilePath | searchInPath() const |
| Utils::FilePath | searchInPath(const Utils::FilePaths &additionalDirs, Utils::FilePath::PathAmending amending = AppendToPath, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const |
| void | setParts(const QStringView scheme, const QStringView host, const QStringView path) |
| Utils::Result<> | setPermissions(QFileDevice::Permissions permissions) const |
| QString | shortNativePath() const |
| bool | startsWithDriveLetter() const |
| Utils::FilePath | stringAppended(const QString &str) const |
| QString | suffix() const |
| QStringView | suffixView() const |
| Utils::FilePath | symLinkTarget() const |
| std::optional<Utils::FilePath> | tailRemoved(const QString &str) const |
| Utils::Result<Utils::FilePath> | tmpDir() const |
| QString | toFSPathString() const |
| QFileInfo | toFileInfo() const |
| QVariant | toSettings() const |
| QUrl | toUrl() const |
| QString | toUrlishString() const |
| QString | toUserOutput() const |
| QVariant | toVariant() const |
| Utils::FilePath | withExecutableSuffix() const |
| Utils::FilePath | withNewMappedPath(const Utils::FilePath &newPath) const |
| Utils::FilePath | withNewPath(const QString &newPath) const |
| Utils::FilePath | withSuffix(const QString &suffix) const |
| QString | withTildeHomePath() const |
| Utils::Result<qint64> | writeFileContents(const QByteArray &data) const |
| Utils::FilePath | operator/(const QString &str) const |
| Utils::FilePath & | operator/=(const QString &str) |
정적 공용 멤버
| Utils::FilePath | currentWorkingPath() |
| Utils::FilePath | fromFileInfo(const QFileInfo &info) |
| Utils::FilePath | fromParts(const QStringView scheme, const QStringView host, const QStringView path) |
| Utils::FilePath | fromPathComponents(const QList<QStringView> &components) |
| Utils::FilePath | fromPathPart(const QStringView path) |
| Utils::FilePath | fromSettings(const QVariant &variant) |
| Utils::FilePath | fromString(const QString &filepath) |
| Utils::FilePath | fromStringWithExtension(const QString &filepath, const QString &defaultExtension) |
| Utils::FilePath | fromUrl(const QUrl &url) |
| Utils::FilePath | fromUserInput(const QString &filePath) |
| Utils::FilePath | fromUtf8(const char *filename, int filenameSize = -1) |
| Utils::FilePath | fromVariant(const QVariant &variant) |
| void | iterateDirectories(const Utils::FilePaths &dirs, const Utils::FilePath::IterateDirCallback &callBack, const Utils::FileFilter &filter) |
| void | removeDuplicates(Utils::FilePaths &files) |
| void | sort(Utils::FilePaths &files) |
| std::vector<Utils::Result<std::unique_ptr<Utils::FilePathWatcher>>> | watch(const Utils::FilePaths &paths) |
상세 설명
이상적으로는 모든 Qt Creator 코드가 이 목적을 위해 FilePath를 사용해야 하지만, 역사적인 이유로 여전히 QString 를 사용하는 부분이 많습니다.
파일 경로(FilePaths)는 내부적으로 세 개의 문자열로 구성된 튜플로 저장되며, 첫 번째 부분("scheme")은 액세스 방식을, 두 번째 부분("host")은 파일 시스템(예: 호스트)을, 세 번째 부분("path")은 시스템상의 (잠재적인) 객체를 식별합니다.
FilePath는 "모든 것은 파일이다"라는 유닉스 패러다임을 따릅니다. 즉, 일반 파일을 가리키는 FilePath와 디렉터리를 가리키는 FilePath 사이에는 개념적인 차이가 없습니다.
파일 경로는 호스트 부분을 통해 운영 체제와 암묵적으로 연결됩니다. 파일 경로의 경로 부분은 관련 운영 체제와 무관하게 내부적으로 슬래시(/)로 저장됩니다.
Windows(및 macOS, 설정에서 달리 선택하지 않은 경우)와 연관된 FilePath의 경로 부분은 대소문자를 구분하지 않고 서로 비교됩니다. 동일성 비교에는 일반적으로 외부 정보가 필요하다는 점에 유의하십시오. 동일한 파일에 대해 여러 FilePath 표현이 존재할 수 있기 때문입니다(예: 서로 다른 액세스 방법이 동일한 파일로 이어질 수 있음).
FilePath와 다른 문자열 형태의 표현 사이에는 다음과 같은 여러 가지 변환이 있습니다:
- FilePath::fromUserInput()
Qt Creator 외부 출처(예: GUI 컨트롤의 사용자 입력, 환경 변수, 명령줄 매개변수)에서 비롯된 문자열 유사 데이터를 Qt Creator 로 변환합니다.
입력에는 슬래시와 백슬래시가 모두 포함될 수 있으며, 파싱 및 정규화됩니다.
- FilePath::nativePath()
FilePath를 관련 OS의 슬래시 표기법으로 변환하고, 스키마 및 호스트 부분을 제거합니다.
이는 관련 OS의 기능을 활용하는 데 유용하며, 예를 들어 이 FilePath를 관련 OS에서 실행되는 명령의 인수로 전달할 때 유용합니다.
참고: ` CommandLine `에 실행 파일로 전달된` FilePath`는 일반적으로 사용자 코드에서 직접 다루지 않습니다. `Process`는 이를 사용하여 원격 시스템을 식별하고 내부적으로 필요한 변환을 적용합니다.
- FilePath::toFSPathString()
FilePath를 [drive:]/__qtc_devices__/scheme/host/path 형식의 문자열로 변환합니다.
이 결과는 대부분의 경우 원격 환경 및 QDir/QFileInfo 에서도 작동하지만, FilePath를 직접 사용하는 것보다 속도가 느리므로 FilePath로 적절히 포팅하기가 너무 어렵거나 불가능한 경우(예: FilePath를 사용하지 않는 외부 Qt 기반 라이브러리를 사용하는 경우)에만 사용해야 합니다.
- FilePath::toUserOutput()
FilePath를 해당 OS의 슬래시 표기법으로 변환하며, 스키마와 호스트 부분은 유지합니다.
이 형식을 사용하는 경우가 사실상 없기 때문에 원격 경로에는 거의 유용하지 않습니다.
- FilePath::displayName()
FilePath를 관련 OS의 슬래시 표기법으로 변환하고, 스키마와 호스트를 " on <device>" 접미사로 추가합니다.
이는 GUI에서 사용자에게 표시되는 정적 출력에 유용합니다.
- FilePath::fromVariant(), FilePath::toVariant()
이들은 QVariant 기반 API(예: 설정 또는 항목 모델(내부) 데이터)와 연동하는 데 사용됩니다.
- FilePath::toUrlishString()
FilePath를 scheme://host/path 형식의 문자열로 변환합니다.
주로 레거시 코드나 디버깅 목적으로 사용됩니다.
거의 모든 경우에, 위에서 언급한 보다 특화된 변환 방법 중 하나를 사용하는 것이 더 적절합니다.
문자열과 유사한 데이터의 변환은 항상 Qt Creator 코드의 바깥쪽 경계에서 이루어져야 하며, 인바운드 통신에는 fromUserInput() 을 사용하고, 매체에 따라 nativePath() 또는 displayName() 을 사용하여 아웃바운드 통신을 수행해야 합니다.
QVariant 기반 Qt API와의 통신에는 fromVariant() 및 toVariant() 을 사용해야 합니다.
toUrlishString() 의 사용은 코드를 QString 기반 파일 경로에서 FilePath로 변환하여 단계적으로 중단해야 합니다. 단, pathAppended() 또는 이와 유사한 방식과 함께 나중에 사용될 FilePath의 경로 조각은 QString 형식으로 유지해야 합니다.
UNC 경로는 "//"로 시작하는 형식을 유지하며, 이를 통해 식별할 수 있습니다.
멤버 함수 문서
Utils::FilePath FilePath::absoluteFilePath() const
이 경로의 절대 경로를 반환하며, “.” 및 “..” 구성 요소를 해결합니다.
이 경로가 이미 절대 경로인 경우, 불필요한 요소가 제거된 후 있는 그대로 반환됩니다. 이 경로가 상대 경로인 경우, 현재 작업 디렉터리를 기준으로 변환됩니다.
absolutePath() 및 cleanPath()도 참조하십시오 .
Utils::FilePath FilePath::absolutePath() const
이 경로의 상위 디렉터리의 절대 경로를 반환합니다.
이 경로가 상대 경로인 경우, 먼저 현재 작업 디렉터리를 기준으로 경로가 해석됩니다.
absoluteFilePath() 및 parentDir()도 참조하십시오 .
Utils::FileStreamHandle FilePath::asyncCopy(const Utils::Continuation<> &cont, const Utils::FilePath &target) const
이 파일을 target 로 비동기적으로 복사하며, 완료 시 cont 를 호출합니다.
이 작업을 취소하는 데 사용할 수 있는 핸들을 반환합니다.
asyncRead() 및 asyncWrite()도 참조하십시오 .
Utils::FileStreamHandle FilePath::asyncRead(const Utils::Continuation<QByteArray> &cont) const
이 파일을 비동기적으로 읽으며, 작업 완료 시 파일 내용을 사용하여 ` cont `를 호출합니다.
이 작업을 취소하는 데 사용할 수 있는 핸들을 반환합니다.
asyncWrite() 및 asyncCopy()도 참조하십시오 .
Utils::FileStreamHandle FilePath::asyncWrite(const Utils::Continuation<qint64> &cont, const QByteArray &data) const
data 를 이 파일에 비동기적으로 기록하며, 작업 완료 시 기록된 바이트 수를 매개변수로 하여 cont 를 호출합니다.
이 작업을 취소하는 데 사용할 수 있는 핸들을 반환합니다.
asyncRead() 및 asyncCopy()도 참조하십시오 .
QString FilePath::baseName() const
경로를 제외한 파일의 기본 이름을 반환합니다.
기본 이름은 파일 이름에서 첫 번째 '.' 문자 바로 앞까지(해당 문자는 제외)의 모든 문자로 구성됩니다.
qint64 FilePath::bytesAvailable() const
이 경로가 포함된 파일 시스템에서 사용 가능한 바이트 수를 반환하며, 해당 정보를 확인할 수 없는 경우에는 0을 반환합니다.
Utils::FilePath FilePath::canonicalPath() const
이 파일 이름에 존재할 수 있는 심볼릭 링크를 재귀적으로 해결합니다.
Windows에서는 SUBST 및 재마운트된 NTFS 드라이브도 해결합니다. ` QFileInfo::canonicalFilePath()`와 달리, 이 함수는 경로가 존재하지 않더라도 빈 문자열을 반환하지 않습니다.
정규화된 경로를 반환합니다.
Utils::FilePath FilePath::chopped(int n) const
로컬 경로에서 ‘ n ’ 문자를 제거한 경로를 반환합니다. 사용 예시:
backup = FilePath("/tmp/example.txt.backup"); real = backup.chopped(7); assert(real == FilePath("/tmp/example.txt"))
Utils::FilePath FilePath::cleanPath() const
QDir::cleanPath() 와 유사하게 경로 부분을 정리합니다.
- 디렉터리 구분 기호를 정규화하고(즉, 플랫폼 고유의 구분 기호를 "/"로 변환하며), 중복된 구분 기호를 제거하며, "."와 ".."를 (가능한 한) 해결합니다.
- 심볼릭 링크는 유지됩니다. 이 함수는 정규화된 경로를 반환하는 것이 아니라, 입력의 가장 단순한 버전을 반환합니다. 예를 들어, "./local"은 "local"이 되고, "local/../bin"은 "bin"이 되며, "/local/usr/../bin"은 "/local/bin"이 됩니다.
void FilePath::clear()
이 FilePath 를 빈 상태로 초기화하여 스킴, 호스트 및 경로를 지웁니다.
QString FilePath::completeBaseName() const
경로를 제외한 파일의 전체 기본 이름을 반환합니다.
전체 기본 이름은 파일 이름에서 마지막 '.' 문자 직전(해당 문자는 제외)까지의 모든 문자로 구성됩니다. ".ui.qml"의 경우, 이는 하나의 확장자로 처리됩니다.
QString FilePath::completeSuffix() const
파일의 전체 접미사(확장자)를 반환합니다.
전체 확장자는 파일 이름에서 첫 번째 '.' 이후(첫 번째 '.'는 제외)에 나오는 모든 문자로 구성됩니다.
bool FilePath::contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseInsensitive) const
path() 에 s 가 포함되어 있는지 여부를 반환합니다.
Utils::Result<> FilePath::copyFile(const Utils::FilePath &target) const
이 파일을 target 로 복사합니다.
장치 간 복사(즉, 서로 다른 스킴/호스트 조합 간)는 모든 콘텐츠를 읽은 후 대상에 기록하는 방식으로 처리됩니다. 성공 시 유효한 Result<> 를 반환하고, 실패 시 오류 결과를 반환합니다.
copyRecursively() 및 renameFile()도 참조하십시오 .
Utils::Result<> FilePath::copyRecursively(const Utils::FilePath &target) const
이 경로의 디렉터리 또는 파일을 target 로 재귀적으로 복사합니다.
성공 시 유효한 Result<> 객체를 반환하고, 실패 시 오류 결과를 반환합니다.
copyFile() 및 renameFile()도 참조하십시오 .
bool FilePath::createDir() const
이 위치에 디렉터리를 생성합니다.
디렉터리가 생성된 경우 true를, 생성되지 않은 경우 false를 반환합니다. 이전에 해당 디렉터리가 존재했더라도 마찬가지입니다.
ensureWritableDir()도 참조하십시오 .
Utils::Result<> FilePath::createSymLink(const Utils::FilePath &symLink) const
이 파일 경로를 가리키는 심볼릭 링크 symLink 를 생성합니다.
참고: Windows에서는 관리자 권한이 있거나 개발자 모드가 활성화되어 있지 않으면 이 함수가 작동하지 않습니다.
Utils::Result<Utils::FilePath> FilePath::createTempDir() const
이 경로를 템플릿으로 사용하여 새로운 임시 디렉터리를 생성합니다.
성공 시 생성된 임시 디렉터리의 경로를 반환하고, 실패 시 오류 결과를 반환합니다. 더 이상 필요하지 않을 때 디렉터리를 삭제하는 것은 호출자의 책임입니다.
Utils::Result<Utils::FilePath> FilePath::createTempFile() const
이 경로를 템플릿으로 사용하여 새로운 임시 파일을 생성합니다.
성공 시 생성된 임시 파일의 경로를 반환하고, 실패 시 오류 결과를 반환합니다. 더 이상 필요하지 않을 때 파일을 삭제하는 것은 호출자의 책임입니다.
[static] Utils::FilePath FilePath::currentWorkingPath()
현재 작업 디렉터리를 ` FilePath` 형식으로 반환합니다.
Utils::Environment FilePath::deviceEnvironment() const
이 경로가 속한 장치의 환경을 반환합니다.
로컬 경로의 경우, 이는 시스템 환경입니다. 원격 경로의 경우, 해당 장치의 환경을 조회합니다. 실패 시 빈 환경을 반환하며, 실패 시 예외를 발생시킵니다.
deviceEnvironmentWithError()도 참조하십시오 .
Utils::Result<Utils::Environment> FilePath::deviceEnvironmentWithError() const
이 경로가 속한 장치의 환경을 반환하거나, 실패 시 오류 결과를 반환합니다.
deviceEnvironment()도 참조하십시오 .
Utils::FilePaths FilePath::devicePathEnvironmentVariable() const
이 경로가 속한 장치의 PATH 디렉터리를 반환하며, 각 항목에는 이 경로의 스키마와 호스트가 적용됩니다.
Utils::FilePaths FilePath::dirEntries(QDir::Filters filters) const
filters 에 해당하는 디렉터리의 항목을 반환합니다.
iterateDirectory()도 참조하십시오 .
Utils::FilePaths FilePath::dirEntries(const Utils::FileFilter &filter, QDir::SortFlags sort = QDir::NoSort) const
filter 에 해당하는 디렉터리의 항목을 반환하며, 선택적으로 sort 에 따라 정렬할 수 있습니다.
iterateDirectory()도 참조하십시오 .
QString FilePath::displayName(const QString &args = {}) const
파일 경로를 해당 OS의 슬래시 표기법으로 변환하고, 스키마와 호스트를 “ on <device>” 형식의 접미사로 추가합니다.
이는 GUI에서 사용자에게 표시되는 정적 출력에 유용합니다.
args 가 비어 있지 않은 경우, 파일 경로 뒤에 "<path> <args> on <device>" 형식으로 출력에 추가됩니다.
bool FilePath::endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseInsensitive) const
path() 가 s 로 끝나는지 여부를 반환합니다.
bool FilePath::ensureExistingFile() const
해당 경로에 파일이 아직 존재하지 않으면 파일을 생성합니다.
파일이 존재하거나 성공적으로 생성된 경우 ` true `를 반환하고, 그렇지 않은 경우 ` false `를 반환합니다.
Utils::Result<> FilePath::ensureReachable(const Utils::FilePath &other) const
이 장치에서 other 에 접속할 수 있는지 확인합니다.
로컬 경로의 경우, other 도 로컬에 있을 때만 성공합니다. 원격 경로의 경우, 필요한 연결을 설정하기 위해 기기 후크가 호출됩니다.
other 에 접속할 수 있는 경우 성공한 Result<> 를 반환하고, 그렇지 않은 경우 오류 결과를 반환합니다.
Utils::Result<> FilePath::ensureWritableDir() const
이 위치에 있는 디렉터리를 재사용하거나 새로 생성합니다.
디렉터리가 존재하고 이후 쓰기 권한이 부여된 경우 성공한 ` Result<> `를 반환하고, 디렉터리를 생성하거나 액세스할 수 없었던 이유를 설명하는 오류 결과를 반환합니다.
createDir()도 참조하십시오 .
bool FilePath::equalsCaseSensitive(const Utils::FilePath &other) const
이 파일 경로가 대소문자를 구분하여 other 와 일치할 경우 true 를 반환합니다. 이는 NTFS를 사용하는 Windows와 같이 대소문자를 부분적으로 구분하는 시스템에서 관련이 있습니다.
QTCREATORBUG-30846도 참조하십시오 .
bool FilePath::exists() const
FilePath 에 해당하는 파일이나 디렉터리가 존재하는지 여부를 나타내는 bool 값을 반환합니다.
Utils::Result<QByteArray> FilePath::fileContents(qint64 maxSize = -1, qint64 offset = 0) const
파일의 내용을 읽어와 반환합니다.
maxSize 가 -1이 아닌 경우, 최대 maxSize 바이트가 읽힙니다. 읽기는 바이트 위치 offset 에서 시작됩니다.
파일을 읽을 수 없는 경우 오류 결과를 반환합니다.
writeFileContents()도 참조하십시오 .
QString FilePath::fileName() const
디렉터리 경로를 제외한 마지막 경로 구성 요소(파일 이름)를 ` QString` 형식으로 반환합니다.
fileNameView(), baseName(), suffix()도 참조하십시오 .
QStringView FilePath::fileNameView() const
디렉터리 경로를 제외한 마지막 경로 구성 요소(파일 이름)를 ` QStringView` 유형으로 반환합니다.
fileName()도 참조하십시오 .
QString FilePath::fileNameWithPathComponents(int pathComponents) const
pathComponents 에 포함된 선행 디렉터리 구성 요소를 포함한 파일 이름을 반환합니다.
- pathComponents 가 0인 경우, 파일 이름만 반환됩니다.
- pathComponents 가 -1인 경우, 전체 경로가 반환됩니다.
- 경로 구성 요소의 수가 pathComponents 보다 적을 경우, 전체 URL과 유사한 문자열이 반환됩니다.
qint64 FilePath::fileSize() const
파일의 크기를 바이트 단위로 반환하며, 크기를 파악할 수 없는 경우에는 0을 반환합니다.
[static] Utils::FilePath FilePath::fromFileInfo(const QFileInfo &info)
info 를 기반으로 FilePath 를 생성합니다.
[static] Utils::FilePath FilePath::fromParts(const QStringView scheme, const QStringView host, const QStringView path)
scheme, host, path 부분들을 조합하여 FilePath 를 생성합니다.
scheme(), host(), path()도 참조하십시오 .
[static] Utils::FilePath FilePath::fromPathComponents(const QList<QStringView> &components)
주어진 경로 components 에 '/'를 연결하여 로컬 FilePath 를 생성합니다.
components 가 비어 있으면, 빈 FilePath 가 반환됩니다. 첫 번째 구성 요소가 '/'인 경우, 결과 경로는 절대 경로가 됩니다.
pathComponents()함수도 참조하십시오 .
[static] Utils::FilePath FilePath::fromPathPart(const QStringView path)
경로 부분만 path 로 설정된 로컬 FilePath 를 생성합니다. 스킴 및 호스트 부분은 비워 둡니다.
[static] Utils::FilePath FilePath::fromSettings(const QVariant &variant)
toSettings() 에 저장된 QVariant variant 를 기반으로 FilePath 를 생성합니다.
toSettings() 및 fromVariant()도 참조하십시오 .
[static] Utils::FilePath FilePath::fromString(const QString &filepath)
FilePath 를 filepath
filepath 의 유효성은 검사되지 않습니다. 다음 형식으로 지정할 수 있습니다:
- /some/absolute/local/path
- some/relative/path
- scheme://host/absolute/path
- scheme://host/./relative/path
참고: ./는 경로의 문자 그대로의 일부입니다.
filepath 을 구문 분석할 때 일부 디코딩이 발생합니다. 호스트 부분에 있는 %25 시퀀스는 호스트 이름에서 %로 대체되고, 호스트 부분에 있는 %2f 시퀀스는 호스트 이름에서 /로 대체됩니다.
경로 부분은 플랫폼이나 파일 시스템에 관계없이 /로 구분된 여러 부분으로 구성될 수 있습니다.
경로 구분자로 백슬래시가 포함될 수 있는 문자열에서 FilePath 객체를 생성하려면 fromUserInput 를 사용하십시오.
toFSPathString, toUserOutput 및 fromUserInput도 참조하십시오 .
[static] Utils::FilePath FilePath::fromStringWithExtension(const QString &filepath, const QString &defaultExtension)
filepath 를 기반으로 FilePath 을 생성합니다. filepath 에 확장자가 이미 없는 경우, defaultExtension 가 해당 파일에 추가됩니다.
filepath 유효성 검사는 수행되지 않습니다.
[static] Utils::FilePath FilePath::fromUrl(const QUrl &url)
url 를 사용하여 FilePath 를 생성합니다.
toUrl()도 참조하십시오 .
[static] Utils::FilePath FilePath::fromUserInput(const QString &filePath)
다음 경로에서 FilePath 를 생성합니다. filePath
filePath 경로에서 불필요한 부분이 제거되고, ~는 홈 경로로 대체됩니다.
[static] Utils::FilePath FilePath::fromUtf8(const char *filename, int filenameSize = -1)
UTF-8로 인코딩된 filenameSize 를 사용하여 filename 에서 FilePath 를 생성합니다.
filename 유효성 검사는 수행되지 않습니다.
[static] Utils::FilePath FilePath::fromVariant(const QVariant &variant)
variant 를 사용하여 FilePath 를 생성합니다.
toVariant()도 참조하십시오 .
QString FilePath::group() const
이 파일의 소유자 그룹 이름을 반환하며, 해당 정보가 없는 경우 빈 문자열을 반환합니다.
uint FilePath::groupId() const
이 파일의 소유자인 그룹의 숫자형 그룹 ID를 반환하며, 해당 정보가 없는 경우 0을 반환합니다.
bool FilePath::hasHardLinks() const
이 경로의 파일에 하드 링크가 두 개 이상 있으면 true 를 반환합니다.
QStringView FilePath::host() const
FilePath 의 호스트 부분을 반환하여 원격 파일 시스템을 식별합니다.
로컬 경로의 경우 빈 ` QStringView `를 반환합니다.
scheme(), path(), fromParts()도 참조하십시오 .
Utils::FilePath FilePath::intern() const
데이터가 인터닝된 복사본을 반환합니다.
bool FilePath::isAbsolutePath() const
경로가 절대 경로인지 확인합니다.
경로가 슬래시(/)로 시작하거나, 문자와 콜론(:)으로 시작하거나, 콜론(:)과 슬래시(/)로 시작하는 경우 true를 반환합니다.
참고: 이 기능은 현재 Qt Creator 가 실행되는 플랫폼과 무관하므로, 반드시 해당 플랫폼의 절대 경로 정의와 일치하는 것은 아닙니다. 주의하여 사용하시고, 가급적 피하는 것이 좋습니다.
isRelativePath()도 참조하십시오 .
bool FilePath::isChildOf(const Utils::FilePath &s) const
FilePath 가 s 의 자식 노드인지 여부를 반환합니다.
bool FilePath::isEmpty() const
경로 부분이 비어 있으면 ` true `을 반환합니다. 스킴과 호스트는 고려되지 않습니다.
bool FilePath::isExecutableFile() const
이 파일이 실행 파일인지 여부를 나타내는 bool 값을 반환합니다.
bool FilePath::isLocal() const
이 경로가 로컬 파일 시스템을 가리키는 경우(스키마가 없거나 "file" 스키마인 경우), true 을 반환합니다.
bool FilePath::isNewerThan(const QDateTime &timeStamp) const
이 파일이나 디렉터리가 timeStamp 보다 최신 버전일 경우 true 을 반환합니다.
디렉터리의 경우, 포함된 모든 파일을 재귀적으로 검사하며, 그중 하나라도 timeStamp 보다 최신인 경우 true 를 반환합니다.
bool FilePath::isRelativePath() const
경로가 상대 경로인지 확인합니다.
경로가 슬래시로 시작하지도 않고, 문자와 콜론으로 시작하지도 않으며, 콜론과 슬래시로 시작하지도 않는 경우 true를 반환합니다.
참고: 이 함수는 현재 Qt Creator 가 실행되는 플랫폼과 무관하므로, 반드시 해당 플랫폼의 상대 경로 정의와 일치하는 것은 아닙니다. 신중하게 사용하시고, 가급적 피하는 것이 좋습니다.
isAbsolutePath()도 참조하십시오 .
bool FilePath::isResourceFile() const
이 경로가 Qt 리소스 파일을 가리키는 경우, 즉 "qrc" 스키마를 갖거나 경로가 ':'로 시작하는 경우, true 를 반환합니다.
bool FilePath::isRootPath() const
이 경로가 파일 시스템의 루트(예: 유닉스의 "/" 또는 윈도우의 "C:/")인 경우, ` true `를 반환합니다.
bool FilePath::isSameDevice(const Utils::FilePath &other) const
other 가 이 경로와 동일한 장치(스킴 및 호스트)를 가리키는 경우, true 를 반환합니다.
bool FilePath::isSameExecutable(const Utils::FilePath &other) const
other 가 ".exe"나 ".bat"와 같은 플랫폼별 확장자를 포함하여 이 경로와 동일한 실행 파일을 가리키는 경우, true 를 반환합니다.
isSameFile()도 참조하십시오 .
bool FilePath::isSameFile(const Utils::FilePath &other) const
other 가 이 경로와 동일한 파일을 가리키는 경우 true 를 반환합니다.
두 경로는 문자열이 동일하지 않더라도(예: 심볼릭 링크나 다른 액세스 방식을 사용하는 경우) 동일한 파일을 가리킬 수 있습니다. 이 함수는 경로가 다를 때 비교를 위해 장치의 파일 ID를 사용합니다.
isSameExecutable() 및 isSameDevice()도 참조하십시오 .
bool FilePath::isWritableDir() const
이 디렉터리가 쓰기 가능한지 여부를 나타내는 bool 값을 반환합니다.
bool FilePath::isWritableFile() const
이 파일이 쓰기 가능한 파일인지 여부를 나타내는 bool 값을 반환합니다.
[static] void FilePath::iterateDirectories(const Utils::FilePaths &dirs, const Utils::FilePath::IterateDirCallback &callBack, const Utils::FileFilter &filter)
dirs 의 각 항목에서 filter 에 일치하는 디렉터리 항목마다 callBack 를 실행합니다.
iterateDirectory()도 참조하십시오 .
void FilePath::iterateDirectory(const Utils::FilePath::IterateDirCallback &callBack, const Utils::FileFilter &filter) const
filter 에 일치하는 각 디렉터리 항목에 대해 callBack 을 실행합니다.
QDateTime FilePath::lastModified() const
이 파일 또는 디렉터리가 마지막으로 수정된 날짜와 시간을 반환합니다.
수정 시간을 확인할 수 없는 경우, 유효하지 않은 ` QDateTime `를 반환합니다.
Utils::Result<Utils::FilePath> FilePath::localSource() const
로컬 파일 시스템에서 액세스할 수 있는 동일한 파일을 나타내는 ` FilePath `를 반환하거나, 해당 매핑이 없는 경우 오류 결과를 반환합니다.
로컬 경로의 경우 ` *this`을 반환합니다. 원격 경로의 경우 디바이스 후크를 참조합니다.
Utils::Result<> FilePath::makeWritable() const
이 파일의 소유자에게 쓰기 권한을 부여합니다.
성공 시 Result<> 를 반환하고, 실패 시 오류 결과를 반환합니다.
setPermissions() 및 permissions()도 참조하십시오 .
QString FilePath::nativePath() const
대상 시스템의 네이티브 명령어에 전달할 수 있도록, 장치 접두사가 제거된 QString 을 반환합니다.
구분 기호를 이 경로가 속한 시스템의 네이티브 형식으로 변환합니다.
Utils::OsType FilePath::osType() const
이 경로가 속한 장치의 OS 유형을 반환합니다.
로컬 경로의 경우 호스트의 OS 유형을 반환합니다. 원격 경로의 경우 해당 장치의 OS 유형을 조회합니다.
QString FilePath::owner() const
이 파일의 소유자인 사용자의 이름을 반환하며, 정보를 확인할 수 없는 경우에는 빈 문자열을 반환합니다.
uint FilePath::ownerId() const
이 파일의 소유자에 대한 숫자형 사용자 ID를 반환하며, 해당 정보가 없는 경우에는 0을 반환합니다.
Utils::FilePath FilePath::parentDir() const
파일 경로의 상위 디렉터리를 찾습니다.
파일 경로가 이미 최상위 디렉터리인 경우 빈 파일 경로를 반환합니다.
마지막 세그먼트가 제거된 파일 경로를 반환합니다.
QString FilePath::path() const
FilePath 의 경로 부분을 슬래시(/)를 사용하여 QString 형식으로 반환합니다.
pathView(), scheme() 및 host()도 참조하십시오 .
Utils::FilePath FilePath::pathAppended(const QString &path) const
이 경로 뒤에 ' path '를 '/'로 연결하여 반환합니다.
path 내의 백슬래시는 슬래시로 정규화됩니다. 이는 operator/(path) 과 동일합니다.
stringAppended() 및 operator/()도 참조하십시오 .
QChar FilePath::pathComponentSeparator() const
이 경로의 경로 구성 요소 구분자를 반환합니다.
경로의 구분자를 반환합니다.
QList<QStringView> FilePath::pathComponents() const
'/' 경계를 기준으로 경로를 구성 요소별로 분할하여 반환합니다.
Windows 경로의 경우, 드라이브 문자(예: "C:")와 루트 슬래시는 별도의 선행 구성 요소로 반환됩니다.
선두에 있는 '/'는 하나의 '/' 구성 요소로 반환됩니다.
fromPathComponents()도 참조하십시오 .
QChar FilePath::pathListSeparator() const
이 경로의 운영 체제에 해당하는 PATH 목록 구분자를 반환합니다. Windows에서는 ';', 그 외의 운영 체제에서는 ':'입니다.
QStringView FilePath::pathView() const
FilePath 의 경로 부분을 슬래시(/)를 사용하여 QStringView 형식으로 반환합니다.
path(), scheme(), host()도 참조하십시오 .
QFileDevice::Permissions FilePath::permissions() const
이 파일 또는 디렉터리의 권한을 반환합니다.
권한을 확인할 수 없는 경우 빈 권한 집합을 반환합니다.
setPermissions() 및 makeWritable()도 참조하십시오 .
std::optional<Utils::FilePath> FilePath::prefixRemoved(const QString &str) const
경로 부분의 맨 앞에서 str 를 제거한 경로를 반환하거나, 경로가 str 로 시작하지 않는 경우 std::nullopt 를 반환합니다.
Utils::TextEncoding FilePath::processStdErrEncoding() const
해당 기기의 프로세스에서 표준 오류 출력에 사용하는 텍스트 인코딩을 반환합니다.
Utils::TextEncoding FilePath::processStdOutEncoding() const
해당 기기에서 프로세스가 표준 출력에 사용하는 텍스트 인코딩을 반환합니다.
std::optional<Utils::FilePath> FilePath::refersToExecutableFile(Utils::FilePath::MatchScope matchScope) const
이 FilePath 의 네이티브 경로를 가진 프로세스가 시작될 가능성이 있는지 여부를 나타내는 bool 값을 반환합니다.
이는 일반적으로 isExecutableFile()과 동일합니다. Windows에서는 matchScope 에 따라 다양한 접미사가 추가될 수 있습니다.
Utils::FilePath FilePath::relativeChildPath(const Utils::FilePath &parent) const
parent 에서 현재 위치까지의 상대 경로를 반환합니다.
이 경로가 parent 의 자식 경로가 아닌 경우, 빈 FilePath 를 반환합니다. 결과 값은 절대 "../"로 시작하지 않습니다. 이 경로가 parent 하위에 있지 않은 경우, 대신 relativePathFromDir() 를 사용하십시오.
relativePathFromDir() 및 isChildOf()도 참조하십시오 .
QString FilePath::relativeNativePathFromDir(const Utils::FilePath &anchorDir) const
anchorDir 에서 현재 위치까지의 상대 경로를, 해당 운영 체제의 기본 경로 구분자를 사용하여 반환합니다.
사용 예:
FilePath filePath("C:/foo/b/ar/file.txt"); QString relativePath = filePath.relativePathFromDir(FilePath("C:\\foo\\c")); qDebug() << relativePath;
디버그 출력 결과는 다음과 같습니다. "..\b\ar\file.txt".
relativePathFromDir()도 참조하십시오 .
QString FilePath::relativePathFromDir(const Utils::FilePath &anchorDir) const
anchorDir 디렉터리에서 FilePath 의 상대 경로를 반환합니다. FilePath 및 anchor 디렉터리는 파일이나 디렉터리일 수 있습니다.
사용 예:
FilePath filePath("/foo/b/ar/file.txt"); QString relativePath = filePath.relativePathFromDir(FilePath("/foo/c")); qDebug() << relativePath;
디버그 출력 결과는 "../b/ar/file.txt" 이 됩니다.
relativeNativePathFromDir()도 참조하십시오 .
[static] void FilePath::removeDuplicates(Utils::FilePaths &files)
files 에서 중복 항목을 순서를 유지한 채 그 자리에서 제거합니다.
Utils::Result<> FilePath::removeFile() const
이 경로의 파일을 삭제합니다.
성공 시 Result<> 를 반환하고, 실패 시 오류 결과를 반환합니다.
removeRecursively()도 참조하십시오 .
Utils::Result<> FilePath::removeRecursively() const
이 filePath가 가리키는 디렉터리와 그 하위 디렉터리를 재귀적으로 삭제합니다.
Utils::Result<> FilePath::renameFile(const Utils::FilePath &target) const
이 파일을 target 로 이동(이름 변경)합니다.
target 가 동일한 장치에 있는 경우, 기본 이름 변경 기능이 사용됩니다. 그렇지 않은 경우, 파일이 복사되고 원본은 삭제됩니다. 성공 시 Result<> 를 반환하고, 실패 시 오류 결과를 반환합니다.
copyFile() 및 removeFile()도 참조하십시오 .
Utils::FilePath FilePath::resolvePath(const QString &tail) const
tail 가 상대 경로인 경우, 이 경로 뒤에 tail 를 추가하거나, 절대 경로인 경우 경로 부분만 tail 로 대체합니다(이 경로의 스키마와 호스트는 유지됨).
Utils::FilePath FilePath::resolvePath(const Utils::FilePath &tail) const
테일이 상대 경로인 경우, 여기에 tail 을 추가합니다.
꼬리 부분이 절대 경로인 경우 꼬리 부분을 반환하고, 그렇지 않은 경우 이 값과 꼬리 부분을 더한 결과를 반환합니다.
Utils::FilePath FilePath::resolveSymlinks() const
이 항목이 심볼릭 링크인 경우, 심볼릭 링크를 재귀적으로 해결합니다.
경로 내 어디서든 심볼릭 링크를 해결하려면 canonicalPath 를 참조하십시오. QFileInfo::canonicalFilePath()와 달리, 이 함수는 심볼릭 링크가 끊어진 상태라 하더라도 예상되는 가장 깊은 대상 파일을 반환합니다.
참고: 최대 재귀 깊이 == 16입니다.
심볼릭 링크의 대상 파일 경로를 반환합니다.
QStringView FilePath::scheme() const
FilePath 의 스킴 부분(예: "docker" 또는 "ssh")을 반환합니다.
로컬 경로의 경우 빈 QStringView 를 반환합니다.
host(), path(), fromParts()도 참조하십시오 .
Utils::FilePaths FilePath::searchAllInDirectories(const Utils::FilePaths &dirs, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const
dirs 중 어느 곳에서든 이 파일 이름과 일치하는 모든 실행 파일을 반환하며, 선택적으로 filter 에 따라 필터링하고, matchScope 에 의해 제어되는 실행 파일 확장자 처리를 적용합니다.
searchInDirectories() 및 searchAllInPath()도 참조하십시오 .
Utils::FilePaths FilePath::searchAllInPath() const
관련된 장치의 PATH에 있는 이 이름의 모든 실행 파일을 검색합니다.
Utils::FilePaths FilePath::searchAllInPath(const Utils::FilePaths &additionalDirs, Utils::FilePath::PathAmending amending = AppendToPath, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const
amending 에 따라 additionalDirs 로 확장된, 관련 장치의 PATH에서 이 이름을 가진 모든 실행 파일을 검색합니다. 선택적으로 filter 를 사용하여 결과를 필터링하고, matchScope 에 따라 접미사를 처리합니다.
searchInPath() 및 searchAllInDirectories()도 참조하십시오 .
void FilePath::searchHereAndInParents(const std::function<IterationPolicy (const FilePath &)> &constraint) const
이 디렉터리와 그 상위 디렉터리를 순회하며, 각 디렉터리에 대해 constraint 를 호출합니다.
constraint 가 ' IterationPolicy::Stop '를 반환하거나 루트에 도달하면 반복이 중지됩니다.
Utils::FilePath FilePath::searchHereAndInParents(const QString &fileName, QDir::Filter type) const
이 디렉터리와 그 모든 상위 디렉터리에서 ` type ` 유형의 ` fileName `이라는 이름의 파일 또는 디렉터리를 검색합니다.
첫 번째로 발견된 일치 항목을 반환하거나, 일치하는 항목이 없으면 빈 FilePath 를 반환합니다.
searchHereAndInParents(const QStringList &, QDir::Filter)도 참조하십시오 .
Utils::FilePath FilePath::searchHereAndInParents(const QStringList &fileNames, QDir::Filter type) const
이 디렉터리와 그 상위 디렉터리 전체에서 ` fileNames ` 경로 내에 있는 ` type ` 유형의 파일 또는 디렉터리를 검색합니다.
첫 번째로 발견된 일치 항목을 반환하거나, 일치하는 항목이 없으면 빈 FilePath 를 반환합니다.
searchHereAndInParents(const QString &, QDir::Filter)도 참조하십시오 .
Utils::FilePath FilePath::searchInDirectories(const Utils::FilePaths &dirs, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const
dirs 로 지정된 각 디렉터리 항목에서, 파일 경로의 matchScope 와 filter 가 일치하는 이 객체에 해당하는 바이너리를 검색합니다.
사용 예:
binary = FilePath::fromUrl("docker://123/./make); fullPath = binary.searchInDirectories(binary.deviceEnvironment().path()); assert(fullPath == FilePath::fromUrl("docker://123/usr/bin/make"))
Utils::FilePath FilePath::searchInPath() const
관련된 장치의 PATH에서 이 실행 파일을 검색합니다.
Utils::FilePath FilePath::searchInPath(const Utils::FilePaths &additionalDirs, Utils::FilePath::PathAmending amending = AppendToPath, const Utils::FilePathPredicate &filter = {}, Utils::FilePath::MatchScope matchScope = WithAnySuffix) const
amending 에 따라 additionalDirs 가 추가된 관련 장치의 PATH에서 이 실행 파일을 검색합니다. 선택적으로 filter 를 사용하여 결과를 필터링하고, matchScope 에 따라 확장자를 처리합니다.
실행 파일이 발견되지 않으면 빈 FilePath 를 반환합니다.
searchAllInPath() 및 searchInDirectories()도 참조하십시오 .
void FilePath::setParts(const QStringView scheme, const QStringView host, const QStringView path)
이 FilePath 의 스킴, 호스트 및 경로 부분을 각각 scheme, host, path 으로 설정합니다.
fromParts(), scheme(), host() 및 path()도 참조하십시오 .
Utils::Result<> FilePath::setPermissions(QFileDevice::Permissions permissions) const
이 파일 또는 디렉터리의 권한을 permissions 로 설정합니다.
성공 시 ` Result<> `를 반환하고, 실패 시 오류 결과를 반환합니다.
permissions() 및 makeWritable()도 참조하십시오 .
QString FilePath::shortNativePath() const
네이티브 구분 기호를 사용하는 경로를 반환하며, 유닉스에서는 홈 디렉터리를 '~'로 축약합니다.
toUserOutput() 와 동일하지만, 유닉스에서는 홈 디렉터리 접두사를 '~'로 대체합니다.
[static] void FilePath::sort(Utils::FilePaths &files)
files 를 스킴, 호스트, 경로 순으로 사전순으로 정렬합니다.
bool FilePath::startsWithDriveLetter() const
경로가 Windows 드라이브 문자로 시작하고 그 뒤에 콜론이 오는 경우(예: "C:")에는 ` true `를 반환합니다.
Utils::FilePath FilePath::stringAppended(const QString &str) const
URL과 유사한 문자열 표현에 구분 기호를 삽입하지 않고, str 을 바로 뒤에 추가하여 다시 파싱된 경로를 반환합니다.
pathAppended()도 참조하십시오 .
QString FilePath::suffix() const
파일의 접미사(확장자)를 반환합니다.
접미사는 파일의 마지막 '.' 이후(해당 '.'은 제외)에 있는 모든 문자로 구성됩니다. ".ui.qml"의 경우, 이를 하나의 접미사로 취급합니다.
suffixView()도 참조하십시오 .
QStringView FilePath::suffixView() const
파일의 접미사(확장자)를 QStringView 형식으로 반환합니다.
접미사는 파일의 마지막 '.' 이후('.'은 제외)에 나오는 모든 문자로 구성됩니다. ".ui.qml"의 경우, 이를 하나의 접미사로 처리합니다.
Utils::FilePath FilePath::symLinkTarget() const
이것이 심볼릭 링크가 아닐 경우, 빈 ` FilePath `를 반환합니다.
std::optional<Utils::FilePath> FilePath::tailRemoved(const QString &str) const
경로 부분의 끝에서 str 를 제거한 경로를 반환하거나, 경로가 str 로 끝나지 않는 경우에는 std::nullopt 를 반환합니다.
Utils::Result<Utils::FilePath> FilePath::tmpDir() const
이 경로가 속한 장치의 임시 디렉터리를 반환합니다.
로컬 경로의 경우, 이는 QDir::tempPath() 와 동일합니다. 원격 장치의 경우, TMPDIR, TEMP 또는 TMP 환경 변수가 순서대로 확인되며, Windows 이외의 장치에서는 "/tmp"가 대체 경로로 사용됩니다.
QString FilePath::toFSPathString() const
QString 를 기반으로 하는 API에 전달할 수 있도록 ` QString `를 반환합니다.
이 기능은 /__qtc_devices__/host/path 구성을 사용합니다.
대부분의 경우 원격 설정 및 QDir/QFileInfo 등에서도 작동하지만, FilePath 를 직접 사용하는 것보다 속도가 느리므로, FilePath 로 제대로 이식하기가 너무 어렵거나 불가능한 경우(예: FilePath 를 사용하지 않는 외부 Qt 기반 라이브러리를 사용하는 경우)에만 사용해야 합니다.
fromUserInput()도 참조하십시오 .
QFileInfo FilePath::toFileInfo() const
QFileInfo 를 반환합니다.
QVariant FilePath::toSettings() const
FilePath 를 설정에 저장하기에 적합한 QVariant 형식으로 반환합니다.
fromSettings() 및 toVariant()도 참조하십시오 .
QUrl FilePath::toUrl() const
이 ` FilePath `을 ` QUrl`으로 변환하여 반환합니다.
QString FilePath::toUrlishString() const
QString 기반 API를 통과시키기 위한 QString 를 반환합니다.
참고: 이 API는 더 이상 사용되지 않으며, 적절한 FilePath 를 더 광범위하게 사용하거나, 이것이 불가능한 경우에는 toFSPathString() 로 대체해야 합니다.
이 메서드는 scheme://host/path 구성을 사용하며, fromString 와 함께 코드 경로를 통해 QString 를 거쳐 FilePath 로 전달하는 데 사용됩니다.
이 결과는 QDir 및 QFileInfo 과 함께 사용하는 데 유용하지 않으며, QFileInfo::canonicalFile 과 같은 일부 작업에 의해 파괴됩니다.
toFSPathString()도 참조하십시오 .
QString FilePath::toUserOutput() const
장치 접두사를 포함하여 사용자에게 표시할 ` QString `를 반환합니다.
구분 기호를 이 경로가 속한 시스템의 기본 형식으로 변환합니다.
QVariant FilePath::toVariant() const
FilePath 를 변형(variant) 형태로 반환합니다.
QAbstractItemModels의 저장소(storage)와 같이 타입에 구애받지 않는 내부 인터페이스에 사용됩니다.
[static] std::vector<Utils::Result<std::unique_ptr<Utils::FilePathWatcher>>> FilePath::watch(const Utils::FilePaths &paths)
주어진 각 경로에 대해 ` FilePathWatcher ` 객체를 반환합니다.
반환된 ` FilePathWatcher `는 해당 경로의 파일이 수정, 이름 변경 또는 삭제될 때 신호를 발생시킵니다. 신호는 호출한 스레드에서 발생합니다. 메인 스레드가 아닌 다른 스레드에서 호출된 경우, 신호가 발생하기까지 다소 시간이 걸릴 수 있습니다.
FilePathWatcher도 참조하십시오 .
Utils::FilePath FilePath::withExecutableSuffix() const
이 경로의 복사본을 반환하며, 여기에 Windows의 ".exe"와 같이 플랫폼별 실행 파일 확장자가 추가됩니다.
Utils::FilePath FilePath::withNewMappedPath(const Utils::FilePath &newPath) const
현재 객체와 동일한 장치에 있는 newPath 객체에 해당하는 경로를 반환합니다.
이 과정에서 윈도우 스타일 경로를 적절한 파일 시스템 대소문자 규칙을 적용한 유닉스 스타일 경로로 변환하거나 드라이브 문자를 처리하는 등, 장치별 변환이 포함될 수 있습니다: C:/dev/src -> /c/dev/src
사용 예:
localDir = FilePath("/tmp/workingdir"); executable = FilePath::fromUrl("docker://123/bin/ls") realDir = executable.withNewMappedPath(localDir) assert(realDir == FilePath::fromUrl("docker://123/tmp/workingdir"))
Utils::FilePath FilePath::withNewPath(const QString &newPath) const
현재 객체와 동일한 장치에서 로컬 경로가 newPath 인 FilePath 객체를 반환합니다.
사용 예:
devicePath = FilePath("docker://123/tmp"); newPath = devicePath.withNewPath("/bin/ls"); assert(realDir == FilePath::fromUrl("docker://123/bin/ls"))
Utils::FilePath FilePath::withSuffix(const QString &suffix) const
이 경로 문자열의 복사본을 반환하며, 경로 뒤에 suffix 을 그대로 추가합니다.
파일 확장자와 같은 접미사를 추가할 때 이 함수를 사용하십시오. 디렉터리를 추가하려면 대신 ` pathAppended() ` 또는 ` operator/() `을 사용하십시오.
QString FilePath::withTildeHomePath() const
유닉스 환경에서 사용자의 홈 디렉터리 접두사를 '~'로 대체한 경로를 반환하며, 이는 정리 작업 후 toUrlishString() 를 호출하는 것과 동일합니다.
Windows 환경이나 원격 경로의 경우, toUrlishString() 의 결과가 변경 없이 그대로 반환됩니다.
Utils::Result<qint64> FilePath::writeFileContents(const QByteArray &data) const
파일에 ` data `를 기록하며, 기존 내용은 모두 덮어씁니다.
성공 시 기록된 바이트 수를 반환하고, 실패 시 오류 결과를 반환합니다.
fileContents()도 참조하십시오 .
Utils::FilePath FilePath::operator/(const QString &str) const
이 경로에 str 을 경로 구성 요소로 추가하여 반환하며, 이는 pathAppended()과 동일합니다.
pathAppended()도 참조하십시오 .
Utils::FilePath &FilePath::operator/=(const QString &str)
이 경로의 경로 구성 요소로 str 를 그 자리에서 추가하고, 이에 대한 참조를 반환합니다.
pathAppended() 및 operator/()도 참조하십시오 .
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.