Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

fixed some edge cases when generating symbolic links #855

Merged
merged 1 commit into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion XRTK-Core/Packages/com.xrtk.core/Editor/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using System.Reflection;

[assembly: AssemblyVersion("0.2.17")]
[assembly: AssemblyVersion("0.2.18")]
[assembly: AssemblyTitle("com.xrtk.core.editor")]
[assembly: AssemblyCompany("XRTK")]
[assembly: AssemblyCopyright("Copyright (c) XRTK. All rights reserved.")]
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ public SymbolicLink() { }

public SymbolicLink(string sourceRelativePath, string targetRelativePath)
{
this.sourceRelativePath = sourceRelativePath;
this.targetRelativePath = targetRelativePath;
SourceRelativePath = sourceRelativePath;
TargetRelativePath = targetRelativePath;
}

[SerializeField]
private string sourceRelativePath;

public string SourceRelativePath
{
get => sourceRelativePath.ForwardSlashes();
internal set => sourceRelativePath = value.ForwardSlashes();
get => sourceRelativePath;
internal set => sourceRelativePath = value.ForwardSlashes().Replace(SymbolicLinker.ProjectRoot, string.Empty);
}

public string SourceAbsolutePath
{
get => $"{SymbolicLinker.ProjectRoot}{sourceRelativePath}".ForwardSlashes();
internal set => sourceRelativePath = value.ForwardSlashes().Replace(SymbolicLinker.ProjectRoot, string.Empty);
internal set => sourceRelativePath = value;
}

[SerializeField]
private string targetRelativePath;

public string TargetRelativePath
{
get => targetRelativePath.ForwardSlashes();
internal set => targetRelativePath = value.ForwardSlashes();
get => targetRelativePath;
internal set => targetRelativePath = value.ForwardSlashes().Replace(SymbolicLinker.ProjectRoot, string.Empty);
}
public string TargetAbsolutePath
{
get => $"{SymbolicLinker.ProjectRoot}{targetRelativePath}".ForwardSlashes();
internal set => targetRelativePath = value.ForwardSlashes().Replace(SymbolicLinker.ProjectRoot, string.Empty);
internal set => targetRelativePath = value;
}

[SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static SymbolicLinker()

private static GUIStyle symbolicLinkMarkerStyle;

internal static string ProjectRoot => GitUtilities.RepositoryRootDir;
internal static string ProjectRoot => GitUtilities.RepositoryRootDir.ForwardSlashes();

/// <summary>
/// Is the sync task running?
Expand Down Expand Up @@ -211,7 +211,7 @@ internal static bool Add(this SymbolicLink newLink)
return false;
}

newLink.TargetAbsolutePath = AddSubfolderPathToTarget(newLink.SourceAbsolutePath, newLink.TargetAbsolutePath);
newLink.TargetRelativePath = AddSubfolderPathToTarget(newLink.SourceRelativePath, newLink.TargetRelativePath);

if (!CreateSymbolicLink(newLink))
{
Expand Down Expand Up @@ -349,9 +349,7 @@ private static bool IsSymbolicPath(string path)
}

internal static bool Validate(this SymbolicLink link)
{
return ValidateSymbolicPath(link.TargetAbsolutePath, link.SourceAbsolutePath);
}
=> ValidateSymbolicPath(link.TargetAbsolutePath, link.SourceAbsolutePath);

private static bool ValidateSymbolicPath(string targetAbsolutePath, string sourceAbsolutePath = null)
{
Expand Down
2 changes: 1 addition & 1 deletion XRTK-Core/Packages/com.xrtk.core/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("0.2.17")]
[assembly: AssemblyVersion("0.2.18")]
[assembly: AssemblyTitle("com.xrtk.core")]
[assembly: AssemblyCompany("XRTK")]
[assembly: AssemblyCopyright("Copyright (c) XRTK. All rights reserved.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ public static class StringExtensions
/// <param name="toEncode">String to encode.</param>
/// <returns>Encoded string.</returns>
public static string EncodeTo64(this string toEncode)
{
return Convert.ToBase64String(Encoding.ASCII.GetBytes(toEncode));
}
=> Convert.ToBase64String(Encoding.ASCII.GetBytes(toEncode));

/// <summary>
/// Decodes string from base 64 ASCII.
/// </summary>
/// <param name="encodedData">String to decode.</param>
/// <returns>Decoded string.</returns>
public static string DecodeFrom64(this string encodedData)
{
return Encoding.ASCII.GetString(Convert.FromBase64String(encodedData));
}
=> Encoding.ASCII.GetString(Convert.FromBase64String(encodedData));

/// <summary>
/// Capitalize the first character and add a space before
Expand Down Expand Up @@ -78,33 +74,25 @@ public static string ToProperCase(this string value)
/// Replaces all back slashes in the string with forward slashes.
/// </summary>
public static string ForwardSlashes(this string value)
{
return value.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
}
=> value.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

/// <summary>
/// Replaces all forward slashes in the string with back slashes.
/// </summary>
public static string BackSlashes(this string value)
{
return value.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
}
=> value.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

/// <summary>
/// Returns the URI path, excluding the filename
/// </summary>
public static string PathFromURI(this string value)
{
return value.Substring(0, value.LastIndexOf("/", StringComparison.Ordinal) + 1);
}
=> value.Substring(0, value.LastIndexOf("/", StringComparison.Ordinal) + 1);

/// <summary>
/// Returns the filename from a URI path
/// </summary>
public static string FilenameFromURI(this string value)
{
return value.Substring(value.LastIndexOf("/", StringComparison.Ordinal) + 1, value.Length - value.LastIndexOf("/", StringComparison.Ordinal) - 1);
}
=> value.Substring(value.LastIndexOf("/", StringComparison.Ordinal) + 1, value.Length - value.LastIndexOf("/", StringComparison.Ordinal) - 1);

/// <summary>
/// Creates a relative path from one file or folder to another.
Expand Down
2 changes: 1 addition & 1 deletion XRTK-Core/Packages/com.xrtk.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Mixed Reality",
"DI"
],
"version": "0.2.17",
"version": "0.2.18",
"unity": "2019.4",
"license": "MIT",
"repository": {
Expand Down