initial project folder

This commit is contained in:
ToAallonranta
2020-01-29 10:05:38 +02:00
parent e6d2f9b9ca
commit 837543ed9a
3804 changed files with 100819 additions and 0 deletions

View File

@ -0,0 +1,66 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Text;
using JetBrains.Annotations;
using UnityEngine;
namespace Packages.Rider.Editor.Util
{
public static class FileSystemUtil
{
[NotNull]
public static string GetFinalPathName([NotNull] string path)
{
if (path == null) throw new ArgumentNullException("path");
// up to MAX_PATH. MAX_PATH on Linux currently 4096, on Mac OS X 1024
// doc: http://man7.org/linux/man-pages/man3/realpath.3.html
var sb = new StringBuilder(8192);
var result = LibcNativeInterop.realpath(path, sb);
if (result == IntPtr.Zero)
{
throw new Win32Exception($"{path} was not resolved.");
}
return new FileInfo(sb.ToString()).FullName;
}
public static string FileNameWithoutExtension(string path)
{
if (string.IsNullOrEmpty(path))
{
return "";
}
var indexOfDot = -1;
var indexOfSlash = 0;
for (var i = path.Length - 1; i >= 0; i--)
{
if (indexOfDot == -1 && path[i] == '.')
{
indexOfDot = i;
}
if (indexOfSlash == 0 && path[i] == '/' || path[i] == '\\')
{
indexOfSlash = i + 1;
break;
}
}
if (indexOfDot == -1)
{
indexOfDot = path.Length - 1;
}
return path.Substring(indexOfSlash, indexOfDot - indexOfSlash);
}
public static bool EditorPathExists(string editorPath)
{
return SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX && new DirectoryInfo(editorPath).Exists
|| SystemInfo.operatingSystemFamily != OperatingSystemFamily.MacOSX && new FileInfo(editorPath).Exists;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bdbd564a9fdad0b738e76d030cad1204
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Packages.Rider.Editor.Util
{
internal static class LibcNativeInterop
{
[DllImport("libc", SetLastError = true)]
public static extern IntPtr realpath(string path, StringBuilder resolved_path);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 071c17858dc6c47ada7b2a1f1ded5402
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
using System;
using System.Linq;
using UnityEngine;
namespace Packages.Rider.Editor.Util
{
public static class UnityUtils
{
internal static readonly string UnityApplicationVersion = Application.unityVersion;
public static Version UnityVersion
{
get
{
var ver = UnityApplicationVersion.Split(".".ToCharArray()).Take(2).Aggregate((a, b) => a + "." + b);
return new Version(ver);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3ec9edad2de6c4df3a146b543a0fbc4c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: