fs/FileInfo: un-inline the constructor to reduce header dependencies
This commit is contained in:
parent
7d31659137
commit
579a6ee299
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,8 +4,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Path.hxx"
|
#include "Path.hxx"
|
||||||
#include "lib/fmt/PathFormatter.hxx"
|
|
||||||
#include "lib/fmt/SystemError.hxx"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "time/FileTime.hxx"
|
#include "time/FileTime.hxx"
|
||||||
|
@ -30,15 +28,7 @@ class FileInfo {
|
||||||
public:
|
public:
|
||||||
constexpr FileInfo() noexcept = default;
|
constexpr FileInfo() noexcept = default;
|
||||||
|
|
||||||
explicit FileInfo(Path path, bool follow_symlinks=true) {
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr bool IsRegular() const noexcept {
|
constexpr bool IsRegular() const noexcept {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -12,6 +12,7 @@ fs_sources = [
|
||||||
'List.cxx',
|
'List.cxx',
|
||||||
'LookupFile.cxx',
|
'LookupFile.cxx',
|
||||||
'DirectoryReader.cxx',
|
'DirectoryReader.cxx',
|
||||||
|
'FileInfo.cxx',
|
||||||
]
|
]
|
||||||
|
|
||||||
if is_windows
|
if is_windows
|
||||||
|
|
Loading…
Reference in New Issue