fs/FileInfo: un-inline the constructor to reduce header dependencies

This commit is contained in:
Max Kellermann 2023-10-07 12:26:51 +02:00
parent 7d31659137
commit 579a6ee299
3 changed files with 19 additions and 11 deletions

17
src/fs/FileInfo.cxx Normal file
View File

@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#include "FileInfo.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "lib/fmt/SystemError.hxx"
FileInfo::FileInfo(Path path, bool follow_symlinks)
{
if (!GetFileInfo(path, *this, follow_symlinks)) {
#ifdef _WIN32
throw FmtLastError("Failed to access {}", path);
#else
throw FmtErrno("Failed to access {}", path);
#endif
}
}

View File

@ -4,8 +4,6 @@
#pragma once
#include "Path.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "lib/fmt/SystemError.hxx"
#ifdef _WIN32
#include "time/FileTime.hxx"
@ -30,15 +28,7 @@ class FileInfo {
public:
constexpr FileInfo() noexcept = default;
explicit FileInfo(Path path, bool follow_symlinks=true) {
if (!GetFileInfo(path, *this, follow_symlinks)) {
#ifdef _WIN32
throw FmtLastError("Failed to access {}", path);
#else
throw FmtErrno("Failed to access {}", path);
#endif
}
}
explicit FileInfo(Path path, bool follow_symlinks=true);
constexpr bool IsRegular() const noexcept {
#ifdef _WIN32

View File

@ -12,6 +12,7 @@ fs_sources = [
'List.cxx',
'LookupFile.cxx',
'DirectoryReader.cxx',
'FileInfo.cxx',
]
if is_windows