1
0
mirror of synced 2025-03-02 16:23:21 +01:00

33 lines
1013 B
C#
Raw Normal View History

2019-05-28 16:11:40 -04:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
2019-05-28 16:11:40 -04:00
using System.Threading.Tasks;
using System.Text.RegularExpressions;
2019-05-28 16:11:40 -04:00
namespace Switch_Toolbox.Library.IO
{
public static class IOExtensions
{
public static uint Reverse(this uint x)
{
// swap adjacent 16-bit blocks
x = (x >> 16) | (x << 16);
// swap adjacent 8-bit blocks
return ((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8);
}
2019-05-28 16:55:17 -04:00
//https://stackoverflow.com/questions/2230826/remove-invalid-disallowed-bad-characters-from-filename-or-directory-folder/12800424#12800424
public static string RemoveIllegaleFileNameCharacters(this string str)
{
2019-05-28 16:55:17 -04:00
return string.Join("_", str.Split(Path.GetInvalidFileNameChars()));
}
2019-05-28 16:55:17 -04:00
public static string RemoveIllegaleFolderNameCharacters(this string str)
{
return string.Join("_", str.Split(Path.GetInvalidPathChars()));
}
2019-05-28 16:11:40 -04:00
}
}