修改版本号,弹幕日志路径去除特殊字符
This commit is contained in:
+27
-1
@@ -85,12 +85,13 @@ namespace BarrageGrab
|
|||||||
var room = AppRuntime.RoomCaches.GetCachedWebRoomInfo(msg.RoomId.ToString());
|
var room = AppRuntime.RoomCaches.GetCachedWebRoomInfo(msg.RoomId.ToString());
|
||||||
if(room == null) return;
|
if(room == null) return;
|
||||||
var date = DateTime.Now.ToString("yyyy年MM月dd日直播");
|
var date = DateTime.Now.ToString("yyyy年MM月dd日直播");
|
||||||
dir = Path.Combine(dir, $"({room.WebRoomId}){room?.Owner?.Nickname ?? "-1"}", date);
|
dir = Path.Combine(dir, $"({room.WebRoomId}){room?.Owner?.Nickname ?? "-1"}", date, "场次" + msg.RoomId.ToString());
|
||||||
if (!Directory.Exists(dir))
|
if (!Directory.Exists(dir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
}
|
}
|
||||||
var path = Path.Combine(dir, type + ".txt");
|
var path = Path.Combine(dir, type + ".txt");
|
||||||
|
path = SafePathString(path);
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
File.Create(path).Close();
|
File.Create(path).Close();
|
||||||
@@ -107,6 +108,31 @@ namespace BarrageGrab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将字符串中的特殊字符转换为'?',使其安全用于文件路径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">输入字符串</param>
|
||||||
|
/// <returns>处理后的安全字符串</returns>
|
||||||
|
public static string SafePathString(string input)
|
||||||
|
{
|
||||||
|
//在文件系统中,以下字符通常不允许用于文件名:\ / : * ? " < > |
|
||||||
|
if (string.IsNullOrEmpty(input))
|
||||||
|
return input;
|
||||||
|
|
||||||
|
// 文件系统中不允许的字符
|
||||||
|
char[] invalidChars = Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()).Distinct().ToArray();
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder(input.Length);
|
||||||
|
foreach (char c in input)
|
||||||
|
{
|
||||||
|
result.Append(invalidChars.Contains(c) ? '?' : c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static string LogText(Msg msg, PackMsgType barType)
|
private static string LogText(Msg msg, PackMsgType barType)
|
||||||
{
|
{
|
||||||
var rinfo = AppRuntime.RoomCaches.GetCachedWebRoomInfo(msg.RoomId.ToString());
|
var rinfo = AppRuntime.RoomCaches.GetCachedWebRoomInfo(msg.RoomId.ToString());
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ using System.Runtime.InteropServices;
|
|||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||||
//通过使用 "*",如下所示:
|
//通过使用 "*",如下所示:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.7.7")]
|
[assembly: AssemblyVersion("2.7.8")]
|
||||||
[assembly: AssemblyFileVersion("2.7.7")]
|
[assembly: AssemblyFileVersion("2.7.8")]
|
||||||
[assembly: NeutralResourcesLanguage("zh-CN")]
|
[assembly: NeutralResourcesLanguage("zh-CN")]
|
||||||
|
|||||||
Reference in New Issue
Block a user