Last active
May 12, 2024 20:00
-
-
Save Ed94/452507373293b80cf0e06ded315a6c74 to your computer and use it in GitHub Desktop.
Virtual view for odin source code: Use symbolic links on windows to create a custom view on the file system for large modules in odin for your codebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $path_code = "DEFINE BASE DIRECTORY PATH FOR THE CODEBASE HERE" | |
| $path_virtual_view = 'DEFINE BASE DIRECTORY PATH FOR THE VIRTUAL VIEW HERE' | |
| if (test-path $path_virtual_view) { | |
| Remove-Item -Path $path_virtual_view -Recurse -Force -ErrorAction Ignore | |
| } | |
| New-Item -ItemType Directory -Path $path_virtual_view | |
| $files = Get-ChildItem -Path $path_code -File -Recurse | |
| foreach ($file in $files) | |
| { | |
| # Determine if the file name contains a namespace | |
| $fileName = $file.Name | |
| if ($fileName -match '^(.+?)_(.+)\.odin$') | |
| { | |
| # Extract namespace and actual file name | |
| $namespace = $Matches[1] | |
| $actualFileName = $Matches[2] + ".odin" | |
| $namespaceDir = Join-Path $path_virtual_view $namespace | |
| if (-not (Test-Path $namespaceDir)) { | |
| New-Item -ItemType Directory -Path $namespaceDir | |
| } | |
| $targetFilePath = $file.FullName | |
| $linkPath = Join-Path $namespaceDir $actualFileName | |
| New-Item -ItemType SymbolicLink -Path $linkPath -Value $targetFilePath | |
| } | |
| else | |
| { | |
| # For files without a namespace, create a symbolic link in the its directory of the virtual view | |
| $linkPath = Join-Path $path_virtual_view $fileName | |
| if (-not (Test-Path $linkPath)) { | |
| New-Item -ItemType SymbolicLink -Path $linkPath -Value $file.FullName | |
| } | |
| } | |
| } | |
| Write-Host "Virtual view created successfully." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment