Refactor last commit

This commit is contained in:
Tyrrrz
2025-12-29 20:11:05 +02:00
parent 7c79e0639b
commit 58dd40bf3e

View File

@@ -1,22 +1,20 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace DiscordChatExporter.Core.Utils.Extensions;
public static class PathExtensions
{
// Characters that are invalid on common filesystems.
// This is a union of invalid characters from Windows (NTFS/FAT32), Linux (ext4/XFS), and macOS (HFS+/APFS).
// We use this instead of Path.GetInvalidFileNameChars() because that only returns OS-specific characters,
// not filesystem-specific characters. This means that it's possible to use, for example, an NTFS drive on
// Linux, which would allow the OS to create filenames with '?' but result in errors when writing to the filesystem.
// not filesystem-specific characters. It's possible to use, for example, an NTFS drive on Linux,
// which would make some additional characters invalid that are otherwise valid on Linux.
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1452
private static readonly char[] InvalidFileNameChars =
[
'\0', // Null character - invalid on all filesystems
'/', // Path separator on Unix
'/', // Path separator on Unix and Windows
'\\', // Path separator on Windows
':', // Reserved on Windows (drive letters, NTFS streams)
'*', // Wildcard on Windows