renaming + optimizations
parent
4f0e9ec566
commit
c3bcdeced6
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29709.97
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpPhysFS", "SharpPhysFS\SharpPhysFS.csproj", "{AD6AA182-8C7F-4F3A-AAEF-7BD993D1D262}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NETPhysFS", "SharpPhysFS\NETPhysFS.csproj", "{AD6AA182-8C7F-4F3A-AAEF-7BD993D1D262}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{250EE88E-18B5-4433-ACF0-24A1D81429CF}"
|
||||
ProjectSection(SolutionItems) = preProject
|
|
@ -1,8 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SharpPhysFS
|
||||
namespace MoonTools.NETPhysFS
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
public delegate int InitDelegate();
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<Version>1.0.0</Version>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Description>.NET wrapper for PhysFS</Description>
|
||||
<PackageId>SharpPhysFS</PackageId>
|
||||
<RootNamespace>SharpPhysFS</RootNamespace>
|
||||
<Product>SharpPhysFS</Product>
|
||||
<AssemblyName>SharpPhysFS</AssemblyName>
|
||||
<PackageId>MoonTools.NETPhysFS</PackageId>
|
||||
<RootNamespace>MoonTools.NETPhysFS</RootNamespace>
|
||||
<Product>MoonTools.NETPhysFS</Product>
|
||||
<AssemblyName>MoonTools.NETPhysFS</AssemblyName>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SharpPhysFS
|
||||
namespace MoonTools.NETPhysFS
|
||||
{
|
||||
public sealed partial class PhysFS
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SharpPhysFS
|
||||
namespace MoonTools.NETPhysFS
|
||||
{
|
||||
public class PhysFSLibNotFound : Exception
|
||||
{
|
||||
|
@ -253,11 +253,16 @@ namespace SharpPhysFS
|
|||
/// This call may block while drives spin up. Be forewarned.
|
||||
/// </remarks>
|
||||
/// <returns>An enumeration of paths to available CD-ROM drives.</returns>
|
||||
public string[] GetCdRomDirs()
|
||||
public IEnumerable<string> GetCdRomDirs()
|
||||
{
|
||||
var list = new List<string>();
|
||||
GetCdRomDirsCallback((s) => list.Add(s));
|
||||
return list.ToArray();
|
||||
IntPtr files = Interop.PHYSFS_getCdRomDirs();
|
||||
for (IntPtr ptr = files; Marshal.ReadIntPtr(ptr) != IntPtr.Zero; ptr = IntPtr.Add(ptr, IntPtr.Size))
|
||||
{
|
||||
var strPtr = (IntPtr)Marshal.PtrToStructure(ptr, typeof(IntPtr));
|
||||
var str = Marshal.PtrToStringAnsi(strPtr);
|
||||
if (!IsDirectory(str)) { yield return str; } // the dll seems to be returning directories. boo!
|
||||
}
|
||||
Interop.PHYSFS_freeList(files);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -340,11 +345,16 @@ namespace SharpPhysFS
|
|||
/// <summary>
|
||||
/// Get the current search path.
|
||||
/// </summary>
|
||||
public string[] GetSearchPath()
|
||||
public IEnumerable<string> GetSearchPath()
|
||||
{
|
||||
var list = new List<string>();
|
||||
GetSearchPathCallback((s) => list.Add(s));
|
||||
return list.ToArray();
|
||||
IntPtr files = Interop.PHYSFS_getSearchPath();
|
||||
for (IntPtr ptr = files; Marshal.ReadIntPtr(ptr) != IntPtr.Zero; ptr = IntPtr.Add(ptr, IntPtr.Size))
|
||||
{
|
||||
var strPtr = (IntPtr)Marshal.PtrToStructure(ptr, typeof(IntPtr));
|
||||
var str = Marshal.PtrToStringAnsi(strPtr);
|
||||
if (!IsDirectory(str)) { yield return str; } // the dll seems to be returning directories. boo!
|
||||
}
|
||||
Interop.PHYSFS_freeList(files);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace SharpPhysFS
|
||||
namespace MoonTools.NETPhysFS
|
||||
{
|
||||
public class PhysFSStream : Stream
|
||||
{
|
||||
|
@ -89,19 +89,19 @@ namespace SharpPhysFS
|
|||
return pos + offset;
|
||||
}
|
||||
|
||||
public long Write(byte[] buffer, uint offset, uint count)
|
||||
public long Write(byte[] buffer, uint count)
|
||||
{
|
||||
return PhysFS.LowLevel.Write(handle, buffer, 1, count);
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
Write(buffer, (uint)offset, (uint)count);
|
||||
Write(buffer, (uint)count);
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using SharpPhysFS;
|
||||
using MoonTools.NETPhysFS;
|
||||
|
||||
namespace UnitTests
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace UnitTests
|
|||
public void VersionCheck(byte major, byte minor, byte patch)
|
||||
{
|
||||
using var pfs = new PhysFS("");
|
||||
new SharpPhysFS.Version() { major = major, minor = minor, patch = patch }.Should().BeEquivalentTo(pfs.GetLinkedVersion());
|
||||
new MoonTools.NETPhysFS.Version() { major = major, minor = minor, patch = patch }.Should().BeEquivalentTo(pfs.GetLinkedVersion());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -89,13 +89,10 @@ namespace UnitTests
|
|||
var effectiveCdDrives = DriveInfo.GetDrives()
|
||||
.Where(x => x.DriveType == DriveType.CDRom)
|
||||
.Select(x => x.RootDirectory.FullName)
|
||||
.OrderBy(s => s)
|
||||
.ToArray();
|
||||
|
||||
var enumeratedCdDrives = pfs.GetCdRomDirs();
|
||||
|
||||
Array.Sort(effectiveCdDrives);
|
||||
Array.Sort(enumeratedCdDrives);
|
||||
|
||||
var enumeratedCdDrives = pfs.GetCdRomDirs().OrderBy(s => s);
|
||||
enumeratedCdDrives.Should().BeEquivalentTo(effectiveCdDrives);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SharpPhysFS\SharpPhysFS.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||
|
@ -16,4 +12,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SharpPhysFS\NETPhysFS.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue