//
// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄
// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █
// █__ --█ █__ --█ ◄█ - █
// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█
// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉
// │ Copyright (c) JP Dillingham.
// │
// │ This program is free software: you can redistribute it and/or modify
// │ it under the terms of the GNU Affero General Public License as published
// │ by the Free Software Foundation, version 3.
// │
// │ This program is distributed in the hope that it will be useful,
// │ but WITHOUT ANY WARRANTY; without even the implied warranty of
// │ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// │ GNU Affero General Public License for more details.
// │
// │ You should have received a copy of the GNU Affero General Public License
// │ along with this program. If not, see https://www.gnu.org/licenses/.
// │
// │ This program is distributed with Additional Terms pursuant to Section 7
// │ of the AGPLv3. See the LICENSE file in the root directory of this
// │ project for the complete terms and conditions.
// │
// │ https://slskd.org
// │
// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌
// │ SPDX-FileCopyrightText: JP Dillingham
// │ SPDX-License-Identifier: AGPL-3.0-only
// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈
//
namespace slskd.Files
{
using System;
using System.IO;
///
/// A file on the host filesystem.
///
public record FilesystemFile
{
///
/// The name of the file.
///
public string Name { get; init; }
///
/// The fully qualified name of the file.
///
public string FullName { get; init; }
///
/// The size of the file, in bytes.
///
public long Length { get; init; }
///
/// The file's attributes.
///
public FileAttributes Attributes { get; init; }
///
/// The timestamp at which the file was created.
///
public DateTime CreatedAt { get; init; }
///
/// The timestamp at which the file was last modified.
///
public DateTime ModifiedAt { get; init; }
///
/// Maps a from the specified .
///
/// The FileInfo instance from which to map.
/// A new instance of FilesystemFile.
public static FilesystemFile FromFileInfo(FileInfo i)
{
return new FilesystemFile
{
Name = i.Name,
FullName = i.FullName,
Length = i.Length,
Attributes = i.Attributes,
CreatedAt = i.CreationTimeUtc,
ModifiedAt = i.LastWriteTimeUtc,
};
}
}
}