arrange of proj structure
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="root"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Internal;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class World { }//------------------ end of class ---------------------
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Area"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Internal.FileIO;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// An independent storage area, used as the only folder type in root folder. Contains several
|
||||
/// <see cref="SSD" /> files reference as virtual disc. Data is actually stored in <see
|
||||
/// cref="SSD" />s in certain RAID mode.
|
||||
/// </summary>
|
||||
public partial class Area { }
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="DataHead"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.HighPerformance;
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
public struct SSDSegmentHead
|
||||
{
|
||||
|
||||
[FieldOffset(12)] internal byte size;
|
||||
|
||||
[FieldOffset(0)] internal M128 data;
|
||||
[FieldOffset(13)] public byte selfDefine_1;
|
||||
[FieldOffset(14)] public byte selfDefine_2;
|
||||
[FieldOffset(15)] public byte selfDefine_3;
|
||||
|
||||
[FieldOffset(0)] public int globalID;
|
||||
[FieldOffset(4)] public int nextID;
|
||||
[FieldOffset(8)] public int previousHash;
|
||||
|
||||
public int Size
|
||||
{
|
||||
get => ((int)size) + 1;
|
||||
set
|
||||
{
|
||||
if ((value > 256) || (value < 0)) {
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
size = (byte)(value - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe byte[] GetBytes()
|
||||
{
|
||||
byte[] ret = new byte[16];
|
||||
fixed (M128* vptr = &data)
|
||||
{
|
||||
byte* bptr = (byte*)vptr;
|
||||
for (int i = 0; i < 15; i++) {
|
||||
ret[i] = *bptr;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="DataSegment"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.HighPerformance;
|
||||
using StgSharp.HighPerformance;
|
||||
using StgSharp.Internal.Intrinsic;
|
||||
|
||||
using StgSharp.Mathematics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = World.ssdSegmentLength * 16)]
|
||||
public unsafe struct SSDSegment : IComparable<int>, IComparable<SSDSegment>
|
||||
{
|
||||
|
||||
[FieldOffset(16)] public fixed byte Data[16 * (World.ssdSegmentLength - 1)];
|
||||
[FieldOffset(12)] public int DataHash;
|
||||
[FieldOffset(8)] public int PreviousHash;
|
||||
[FieldOffset(0 * 16)] public SSDSegmentHead Head;
|
||||
|
||||
public SSDSegment(int previousHash)
|
||||
{
|
||||
this.PreviousHash = previousHash;
|
||||
}
|
||||
|
||||
public byte this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index > (16 * (World.ssdSegmentLength - 1)) - 1) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return Data[index];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (index > (16 * (World.ssdSegmentLength - 1)) - 1) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
Data[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int ID
|
||||
{
|
||||
get { return Head.globalID; }
|
||||
set { Head.globalID = value; }
|
||||
}
|
||||
|
||||
public short Size => Head.size;
|
||||
|
||||
public void FillRandomBytes(int begin)
|
||||
{
|
||||
if (begin > 255) {
|
||||
return;
|
||||
}
|
||||
for (int i = begin; i < 255; i++) {
|
||||
Data[i] = Scalar.Random<byte>();
|
||||
}
|
||||
}
|
||||
|
||||
public static SSDSegment FromStream(byte[] stream)
|
||||
{
|
||||
if (stream.Length != 16 * World.ssdSegmentLength) {
|
||||
throw new ArgumentException();
|
||||
}
|
||||
SSDSegment ret = new SSDSegment();
|
||||
fixed (byte* bptr = stream)
|
||||
{
|
||||
ret.Head.data = *(M128*)bptr;
|
||||
for (int i = 1; i < World.ssdSegmentLength; i++) {
|
||||
ret.WriteData<M128>(i - 1, *(M128*)(bptr + (16 * i)));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] ret = new byte[16 * World.ssdSegmentLength];
|
||||
fixed (M128* mptr = &Head.data)
|
||||
{
|
||||
fixed (byte* aptr = ret)
|
||||
{
|
||||
Vector4* vsptr = (Vector4*)mptr;
|
||||
Vector4* vtptr = (Vector4*)aptr;
|
||||
for (int i = 0; i < 18; i++) {
|
||||
*(vtptr + i) = *(vsptr + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int GetDataHash()
|
||||
{
|
||||
Vector4 v = Vector4.One;
|
||||
fixed (M128* mptr = &Head.data)
|
||||
{
|
||||
Vector4* vptr = (Vector4*)mptr;
|
||||
for (int i = 0; i < World.ssdSegmentLength - 1; i += 1) {
|
||||
v += (*vptr) * 31;
|
||||
}
|
||||
}
|
||||
M128 m = new M128(v);
|
||||
DataHash = m.Vec.GetHashCode();
|
||||
return DataHash;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int ret = 17;
|
||||
fixed (M128* mptr = &Head.data)
|
||||
{
|
||||
Vector4* vptr = (Vector4*)mptr;
|
||||
for (int i = 0; i < World.ssdSegmentLength; i++) {
|
||||
ret = (ret + (*vptr).GetHashCode()) * 31;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public unsafe T ReadData<T>(int index) where T: unmanaged
|
||||
{
|
||||
fixed (byte* bptr = Data)
|
||||
{
|
||||
T* tptr = (T*)bptr;
|
||||
return *(tptr + index);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void WriteData<T>(int index, T value) where T: unmanaged
|
||||
{
|
||||
fixed (byte* bptr = Data)
|
||||
{
|
||||
T* tptr = (T*)bptr;
|
||||
*(tptr + index) = value;
|
||||
}
|
||||
}
|
||||
|
||||
int IComparable<int>.CompareTo(int other)
|
||||
{
|
||||
return ID.CompareTo(other);
|
||||
}
|
||||
|
||||
int IComparable<SSDSegment>.CompareTo(SSDSegment other)
|
||||
{
|
||||
return ID.CompareTo(other.ID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="SSD"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Internal.FileIO;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
public partial class SSD
|
||||
{
|
||||
|
||||
private Dictionary<string, SSDraw> fileList;
|
||||
|
||||
private FileStream file;
|
||||
private SSDrawHead head;
|
||||
|
||||
public SSD()
|
||||
{
|
||||
fileList = new Dictionary<string, SSDraw>();
|
||||
}
|
||||
|
||||
public SSD(FileStream fileStream)
|
||||
{
|
||||
fileList = new Dictionary<string, SSDraw>();
|
||||
file = fileStream;
|
||||
}
|
||||
|
||||
public static SSD FromFile(string fileRoute)
|
||||
{
|
||||
return new SSD(new FileStream(fileRoute, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="SSDVirtualFolder"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Internal.FileIO;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
public class SSDFolder : ISSDSerializable
|
||||
{
|
||||
|
||||
internal Dictionary<string, SSDFolder> folders;
|
||||
internal int _folderID;
|
||||
internal string _name;
|
||||
|
||||
internal SSDFolder()
|
||||
{
|
||||
folders = new Dictionary<string, SSDFolder>();
|
||||
}
|
||||
|
||||
internal SSDFolder(string name)
|
||||
{
|
||||
if (name == "root") {
|
||||
throw new ArgumentException(
|
||||
"Name cannot be root," + "it is preserved for root file indexer.");
|
||||
}
|
||||
if (name == "default") {
|
||||
throw new ArgumentException(
|
||||
"Name cannot be default," + "it is preserved for default file id provider.");
|
||||
}
|
||||
_name = name;
|
||||
folders = new Dictionary<string, SSDFolder>();
|
||||
}
|
||||
|
||||
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.VirtualFolder;
|
||||
|
||||
public void FromBytes(byte[] stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// TODO TOUGH TO Get Bytes from virtual folders
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="SSDraw"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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.Graphics.ShaderEdit;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace StgSharp.Internal.FileIO
|
||||
{
|
||||
public class SSDraw
|
||||
{
|
||||
|
||||
private byte[] data;
|
||||
|
||||
public SSDraw(string name, Stream streamSource)
|
||||
{
|
||||
if ((streamSource == null) || (streamSource.Length == 0)) {
|
||||
throw new ArgumentNullException(nameof(streamSource));
|
||||
}
|
||||
Name = name;
|
||||
data = new byte[streamSource.Length];
|
||||
streamSource.Read(data.AsSpan());
|
||||
}
|
||||
|
||||
public SSDrawHead Head { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 32 * 16)]
|
||||
public unsafe struct SSDrawHead { }
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Define"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// A class contains a sets of methods to serialize several types
|
||||
/// </summary>
|
||||
public static partial class Serializer { }
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ISSDSerializable"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
public interface ISSDSerializable
|
||||
{
|
||||
|
||||
public SerializableTypeCode SSDTypeCode { get; }
|
||||
|
||||
public byte[] GetBytes();
|
||||
|
||||
internal void FromBytes(byte[] stream);
|
||||
|
||||
}
|
||||
|
||||
public enum SerializableTypeCode
|
||||
{
|
||||
|
||||
Unknown = 0,
|
||||
IndexTable = 1,
|
||||
PixelImage = 2,
|
||||
VectorImage = 3,
|
||||
Audio = 4,
|
||||
Shader = 5,
|
||||
Text = 6,
|
||||
RawData = 7,
|
||||
VirtualFolder = int.MaxValue,
|
||||
|
||||
}
|
||||
|
||||
public static partial class Serializer
|
||||
{
|
||||
|
||||
public static T Deserialize<T>(byte[] stream) where T: ISSDSerializable
|
||||
{
|
||||
T serializableObject = Activator.CreateInstance<T>();
|
||||
serializableObject.FromBytes(stream);
|
||||
return serializableObject;
|
||||
}
|
||||
|
||||
public static string GetNameTail(SerializableTypeCode typeCode)
|
||||
{
|
||||
switch (typeCode)
|
||||
{
|
||||
case SerializableTypeCode.IndexTable:
|
||||
return "_idt";
|
||||
case SerializableTypeCode.PixelImage:
|
||||
return "_pim";
|
||||
case SerializableTypeCode.VectorImage:
|
||||
return "_vim";
|
||||
case SerializableTypeCode.Audio:
|
||||
return "_wav";
|
||||
case SerializableTypeCode.Shader:
|
||||
return "_gls";
|
||||
case SerializableTypeCode.Text:
|
||||
return "_txt";
|
||||
case SerializableTypeCode.RawData:
|
||||
return "_raw";
|
||||
case SerializableTypeCode.VirtualFolder:
|
||||
return "_fod";
|
||||
default:
|
||||
throw new ArgumentException("Unknown file type");
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Serialize(ISSDSerializable serializableObject)
|
||||
{
|
||||
return serializableObject.GetBytes();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user