daily update on 2024.03.18 by itload youmu

This commit is contained in:
YoumuLiu
2024-03-19 02:41:04 +08:00
parent 15bf989285
commit 0c50c6282e
200 changed files with 7663 additions and 3455 deletions
+59 -26
View File
@@ -1,11 +1,42 @@
using StgSharp.Geometries;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="InternalIO.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries;
using StgSharp.Graphics;
using System.Threading;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
#if Windows
@@ -24,10 +55,6 @@ namespace StgSharp
internal static unsafe partial class InternalIO
{
internal static Dictionary<TypeCode, uint> GLtype =
new Dictionary<TypeCode, uint>();
internal static IntPtr SSClibPtr = IntPtr.Zero;
internal const string SS_errorlog =
"SS_errorlog.log";
@@ -35,9 +62,16 @@ namespace StgSharp
internal const string SSC_libname =
"StgSharpC";
internal static Dictionary<TypeCode, uint> GLtype =
new Dictionary<TypeCode, uint>();
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
internal static readonly GCHandle ssc_logHandle =
GCHandle.Alloc(new byte[512], GCHandleType.Pinned);
internal static IntPtr SSClibPtr = IntPtr.Zero;
static InternalIO()
{
GLtype.Add(TypeCode.Single, GLconst.FLOAT);
@@ -49,6 +83,20 @@ namespace StgSharp
GLtype.Add(TypeCode.Byte, GLconst.UNSIGNED_BYTE);
}
internal static void InternalAppendLog(string log)
{
if (!File.Exists(SS_errorlog))
{
FileStream stream = File.Create(SS_errorlog);
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorlog))
{
logStream.WriteLine(log);
}
}
[Obsolete("Not completed", true)]
internal static IntPtr InternalLoadProc<T>(IntPtr lib, string name) where T : Delegate
{
@@ -68,8 +116,9 @@ namespace StgSharp
}
}
internal static void InternalAppendLog(string log)
internal static void InternalWriteLog(string logLine, LogType logType)
{
logSyncSemaphore.Wait();
if (!File.Exists(SS_errorlog))
{
FileStream stream = File.Create(SS_errorlog);
@@ -78,12 +127,12 @@ namespace StgSharp
using (StreamWriter logStream = File.AppendText(SS_errorlog))
{
logStream.WriteLine(log);
logStream.WriteLine($"{logType}\t@\t{DateTime.Now.ToString("o")}");
logStream.WriteLine(logLine);
}
logSyncSemaphore.Release(1);
}
internal static SemaphoreSlim logSyncSemaphore = new SemaphoreSlim(1, 1);
internal static void InternalWriteLog(string beforeTime, string logLine, LogType logType)
{
logSyncSemaphore.Wait();
@@ -102,21 +151,5 @@ namespace StgSharp
logSyncSemaphore.Release(1);
}
internal static void InternalWriteLog(string logLine, LogType logType)
{
logSyncSemaphore.Wait();
if (!File.Exists(SS_errorlog))
{
FileStream stream = File.Create(SS_errorlog);
stream.Close();
}
using (StreamWriter logStream = File.AppendText(SS_errorlog))
{
logStream.WriteLine($"{logType}\t@\t{DateTime.Now.ToString("o")}");
logStream.WriteLine(logLine);
}
logSyncSemaphore.Release(1);
}
}
}