mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-10 20:02:31 +00:00
Refactor last commit
This commit is contained in:
@@ -1,22 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Utils.Extensions;
|
namespace DiscordChatExporter.Core.Utils.Extensions;
|
||||||
|
|
||||||
public static class PathExtensions
|
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).
|
// 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,
|
// 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
|
// not filesystem-specific characters. It's possible to use, for example, an NTFS drive on Linux,
|
||||||
// Linux, which would allow the OS to create filenames with '?' but result in errors when writing to the filesystem.
|
// which would make some additional characters invalid that are otherwise valid on Linux.
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1452
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/1452
|
||||||
private static readonly char[] InvalidFileNameChars =
|
private static readonly char[] InvalidFileNameChars =
|
||||||
[
|
[
|
||||||
'\0', // Null character - invalid on all filesystems
|
'\0', // Null character - invalid on all filesystems
|
||||||
'/', // Path separator on Unix
|
'/', // Path separator on Unix and Windows
|
||||||
'\\', // Path separator on Windows
|
'\\', // Path separator on Windows
|
||||||
':', // Reserved on Windows (drive letters, NTFS streams)
|
':', // Reserved on Windows (drive letters, NTFS streams)
|
||||||
'*', // Wildcard on Windows
|
'*', // Wildcard on Windows
|
||||||
|
|||||||
Reference in New Issue
Block a user