Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix slash in windows paths #42

Merged
merged 2 commits into from
Jan 22, 2024
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 Runtime/LLM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LLM : LLMClient
private static string GetAssetPath(string relPath = "")
{
// Path to store llm server binaries and models
return Path.Combine(Application.streamingAssetsPath, relPath);
return Path.Combine(Application.streamingAssetsPath, relPath).Replace('\\', '/');
}

#if UNITY_EDITOR
Expand Down
11 changes: 6 additions & 5 deletions Runtime/LLMUnitySetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ public static async Task<string> AddAsset(string assetPath, string basePath)
return null;
}
// add an asset to the basePath directory if it is not already there and return the relative path
Directory.CreateDirectory(basePath);
string fullPath = Path.GetFullPath(assetPath);
if (!fullPath.StartsWith(basePath))
string basePathSlash = basePath.Replace('\\', '/');
string fullPath = Path.GetFullPath(assetPath).Replace('\\', '/');
Directory.CreateDirectory(basePathSlash);
if (!fullPath.StartsWith(basePathSlash))
{
// if the asset is not in the assets dir copy it over
fullPath = Path.Combine(basePath, Path.GetFileName(assetPath));
fullPath = Path.Combine(basePathSlash, Path.GetFileName(assetPath));
Debug.Log($"copying {assetPath} to {fullPath}");
AssetDatabase.StartAssetEditing();
await Task.Run(() =>
Expand All @@ -167,7 +168,7 @@ await Task.Run(() =>
AssetDatabase.StopAssetEditing();
Debug.Log("copying complete!");
}
return fullPath.Substring(basePath.Length + 1);
return fullPath.Substring(basePathSlash.Length + 1);
}

public static void ExtractZip(string zipPath, string extractToPath)
Expand Down
Loading