mirror of
https://github.com/whoeevee/ivinject.git
synced 2026-01-09 00:25:03 +01:00
First commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Text;
|
||||
using ivinject.Common.Models;
|
||||
using ivinject.Features.Packaging.Models;
|
||||
|
||||
namespace ivinject.Features.Injection.Models;
|
||||
|
||||
internal class IviCopiedBinary
|
||||
{
|
||||
internal required IviInjectionEntryType Type { get; init; }
|
||||
internal required IviMachOBinary Binary { get; init; }
|
||||
|
||||
internal string Name => Binary.Name;
|
||||
|
||||
internal string GetRunPath(IviDirectoriesInfo directoriesInfo)
|
||||
{
|
||||
var builder = new StringBuilder("@rpath/");
|
||||
|
||||
builder.Append(
|
||||
Type switch
|
||||
{
|
||||
IviInjectionEntryType.Framework => Path.GetRelativePath(
|
||||
directoriesInfo.FrameworksDirectory,
|
||||
Binary.FullName
|
||||
),
|
||||
IviInjectionEntryType.PlugIn => Path.GetRelativePath(
|
||||
directoriesInfo.PlugInsDirectory,
|
||||
Binary.FullName
|
||||
),
|
||||
_ => Binary.Name
|
||||
}
|
||||
);
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using ivinject.Features.Packaging.Models;
|
||||
|
||||
namespace ivinject.Features.Injection.Models;
|
||||
|
||||
internal class IviInjectionEntry
|
||||
{
|
||||
private readonly FileInfo _fileInfo;
|
||||
internal string FullName => _fileInfo.FullName;
|
||||
internal string Name => _fileInfo.Name;
|
||||
internal IviInjectionEntryType Type => _fileInfo.Extension switch
|
||||
{
|
||||
".dylib" => IviInjectionEntryType.DynamicLibrary,
|
||||
".deb" => IviInjectionEntryType.DebianPackage,
|
||||
".bundle" => IviInjectionEntryType.Bundle,
|
||||
".framework" => IviInjectionEntryType.Framework,
|
||||
".appex" => IviInjectionEntryType.PlugIn,
|
||||
_ => IviInjectionEntryType.Unknown
|
||||
};
|
||||
|
||||
internal IviInjectionEntry(FileInfo fileInfo)
|
||||
=> _fileInfo = fileInfo;
|
||||
|
||||
internal IviInjectionEntry(string filePath)
|
||||
=> _fileInfo = new FileInfo(filePath);
|
||||
|
||||
internal string GetPathInBundle(IviDirectoriesInfo directoriesInfo) =>
|
||||
Type switch
|
||||
{
|
||||
IviInjectionEntryType.DynamicLibrary or IviInjectionEntryType.Unknown =>
|
||||
Path.Combine(
|
||||
Type is IviInjectionEntryType.DynamicLibrary
|
||||
? directoriesInfo.FrameworksDirectory
|
||||
: directoriesInfo.BundleDirectory,
|
||||
Name
|
||||
),
|
||||
IviInjectionEntryType.Framework => Path.Combine(
|
||||
directoriesInfo.FrameworksDirectory,
|
||||
Name
|
||||
),
|
||||
IviInjectionEntryType.PlugIn => Path.Combine(
|
||||
directoriesInfo.PlugInsDirectory,
|
||||
Name
|
||||
),
|
||||
_ => Path.Combine(directoriesInfo.BundleDirectory, Name)
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace ivinject.Features.Injection.Models;
|
||||
|
||||
internal enum IviInjectionEntryType
|
||||
{
|
||||
DynamicLibrary,
|
||||
DebianPackage,
|
||||
Bundle,
|
||||
Framework,
|
||||
PlugIn,
|
||||
Unknown
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ivinject.Features.Injection.Models;
|
||||
|
||||
internal static partial class RegularExpressions
|
||||
{
|
||||
[GeneratedRegex(@"([\/@].*) \(.*\)", RegexOptions.Compiled)]
|
||||
internal static partial Regex OToolSharedLibrary();
|
||||
}
|
||||
Reference in New Issue
Block a user