Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
connffuused authored Apr 25, 2021
1 parent 6d06bd7 commit 8540013
Show file tree
Hide file tree
Showing 16 changed files with 932 additions and 0 deletions.
49 changes: 49 additions & 0 deletions OpenInclude.Utility/OpenInclude.Utility.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{471D9D31-DE12-4242-8AB5-B98FFC7E87AC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenInclude.Utility</RootNamespace>
<AssemblyName>OpenInclude.Utility</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnityInclude.cs" />
<Compile Include="UnityPath.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
36 changes: 36 additions & 0 deletions OpenInclude.Utility/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenInclude.Utility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenInclude.Utility")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("471d9d31-de12-4242-8ab5-b98ffc7e87ac")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
54 changes: 54 additions & 0 deletions OpenInclude.Utility/UnityInclude.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;

namespace OpenInclude.Utility
{
public class UnityInclude
{
private readonly string identityPath;
private readonly string packageDisplayName = string.Empty;
private readonly string packageSubDirectory = string.Empty;

public UnityInclude(string includeLine)
{
var removals = new string[] { "#include", " ", "\t", "\"" };
var path = includeLine;

foreach (var removal in removals)
{
path = path.Replace(removal, "");
}

identityPath = path;

var directoryBlocks = identityPath.Split('/');
for (int i = 0; i < directoryBlocks.Length; i++)
{
if (i == 0) { }
else if (i == 1)
{
packageDisplayName = directoryBlocks[i];
}
else
{
packageSubDirectory += directoryBlocks[i];
if (i != directoryBlocks.Length - 1) packageSubDirectory += "/";
}
}

Console.WriteLine(identityPath);
Console.WriteLine(packageDisplayName);
Console.WriteLine(packageSubDirectory);

}

public string PackageName
{
get { return packageDisplayName; }
}

public string SubDirectory
{
get { return packageSubDirectory; }
}
}
}
73 changes: 73 additions & 0 deletions OpenInclude.Utility/UnityPath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.IO;

namespace OpenInclude.Utility
{
public class UnityPath
{
private string m_path;

public string Root { get; }

public UnityPath(string path)
{
this.m_path = path;

if (path.Contains("Assets"))
{
Root = path.Substring(0, path.IndexOf("Assets", StringComparison.Ordinal) - 1);
}
else if (path.Contains("Packages"))
{
Root = path.Substring(0, path.IndexOf("Packages", StringComparison.Ordinal) - 1);
}
else if (path.Contains("Library\\PackageCache"))
{
Root = path.Substring(0, path.IndexOf("Library\\PackageCache", StringComparison.Ordinal) - 1);
}

Console.WriteLine($"ROOT - {Root}");
}

public string GetResolvedPath(string packageName)
{
DirectoryInfo di;
DirectoryInfo[] subDirs;

di = new DirectoryInfo(Root + "/Packages");
subDirs = di.GetDirectories();

foreach (var dir in subDirs)
{
if (dir.FullName.Contains(packageName))
{
return dir.FullName;
}
}

di = new DirectoryInfo(Root + "/Library/PackageCache");
subDirs = di.GetDirectories();

foreach (var dir in subDirs)
{
if (dir.FullName.Contains(packageName))
{
return dir.FullName;
}
}

di = new DirectoryInfo(Root + "/Assets");
subDirs = di.GetDirectories();

foreach (var dir in subDirs)
{
if (dir.FullName.Contains(packageName))
{
return dir.FullName;
}
}

return string.Empty;
}
}
}
Loading

0 comments on commit 8540013

Please sign in to comment.