-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Export-Pog: Show package name when overwriting an export
1 parent
660c397
commit 1d3402e
Showing
7 changed files
with
78 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
39 changes: 39 additions & 0 deletions
39
app/Pog/lib_compiled/Pog/src/ImportedPackage/GloballyExportedCommand.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Pog.Utils; | ||
using IOPath = System.IO.Path; | ||
|
||
namespace Pog; | ||
|
||
internal class GloballyExportedCommand(string path) { | ||
public readonly string Path = path; | ||
|
||
public bool Exists => FsUtils.FileExistsCaseSensitive(Path); | ||
// take the target path and go ../.. (from `<package>/.commands/name.exe`) | ||
public string? SourcePackagePath => !Exists ? null : IOPath.GetDirectoryName(IOPath.GetDirectoryName(Target)); | ||
public string? Target => FsUtils.GetSymbolicLinkTarget(Path); | ||
|
||
public static GloballyExportedCommand FromLocal(string localExportPath) { | ||
var path = $"{InternalState.PathConfig.ExportedCommandDir}\\{IOPath.GetFileName(localExportPath)}"; | ||
return new(path); | ||
} | ||
|
||
public bool IsFromPackage(ImportedPackage p) => SourcePackagePath == p.Path; | ||
|
||
public void Delete() => File.Delete(Path); | ||
|
||
public void UpdateFrom(FileInfo localCmd) { | ||
FsUtils.CreateSymbolicLink(Path, localCmd.FullName, false); | ||
} | ||
|
||
public IEnumerable<GloballyExportedCommand> EnumerateConflictingCommands() { | ||
var name = IOPath.GetFileNameWithoutExtension(Path); | ||
// filter out files with a dot before the extension (e.g. `arm-none-eabi-ld.bfd.exe`) | ||
return Directory.EnumerateFiles(InternalState.PathConfig.ExportedCommandDir, $"{name}.*") | ||
.Where(cmdPath => string.Equals( | ||
IOPath.GetFileNameWithoutExtension(cmdPath), name, StringComparison.OrdinalIgnoreCase)) | ||
.Select(p => new GloballyExportedCommand(p)); | ||
} | ||
} |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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