Skip to content

Commit

Permalink
fix(paths): support file paths longer than Windows API MAX_PATH const…
Browse files Browse the repository at this point in the history
…ant.
  • Loading branch information
xiaoxiao921 committed Nov 5, 2024
1 parent 1f4ad88 commit 185ded8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
shell: bash
run: |
dotnet build ./DepotDownloader.sln --configuration Release --property:OutputPath=./ReleaseOutput
cp ./RoR2VersionSelector/ReleaseOutput/RoR2VersionSelector.exe ./DepotDownloader/ReleaseOutput/RoR2VersionSelector.exe
cp -r ./RoR2VersionSelector/ReleaseOutput/* ./DepotDownloader/ReleaseOutput/
mv ./DepotDownloader/ReleaseOutput/ ./build
- run: Compress-Archive -Path ./build/* -Destination binary.zip
Expand Down
14 changes: 5 additions & 9 deletions RoR2VersionSelector/RoR2VersionSelector.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net.NetworkInformation;
using Alphaleonis.Win32.Filesystem;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RoR2VersionSelector
Expand Down Expand Up @@ -43,7 +39,7 @@ private bool IsValidDownloadedDepot(string folderName)
return false;
}

foreach (var filePath in Directory.EnumerateFiles(folderName, "Risk of Rain 2.exe", SearchOption.AllDirectories))
foreach (var filePath in Directory.EnumerateFiles(folderName, "Risk of Rain 2.exe", System.IO.SearchOption.AllDirectories))
{
return true;
}
Expand All @@ -60,7 +56,7 @@ private List<string> GetRiskofRain2Folders(string rootPath)
return res;
}

foreach (var filePath in Directory.EnumerateFiles(rootPath, "Risk of Rain 2.exe", SearchOption.AllDirectories))
foreach (var filePath in Directory.EnumerateFiles(rootPath, "Risk of Rain 2.exe", System.IO.SearchOption.AllDirectories))
{
res.Add(Path.GetDirectoryName(filePath));
}
Expand Down Expand Up @@ -181,12 +177,12 @@ private void SetManifestIdAndArgAndOuputFolderPathArg()

private static void CopyFilesRecursively(string sourcePath, string targetPath)
{
foreach (var dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories))
foreach (var dirPath in Directory.GetDirectories(sourcePath, "*", System.IO.SearchOption.AllDirectories))
{
Directory.CreateDirectory(dirPath.Replace(sourcePath, targetPath));
}

foreach (var newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories))
foreach (var newPath in Directory.GetFiles(sourcePath, "*.*", System.IO.SearchOption.AllDirectories))
{
File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true);
}
Expand Down
3 changes: 3 additions & 0 deletions RoR2VersionSelector/RoR2VersionSelector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<TargetFramework>net472</TargetFramework>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AlphaFS" Version="2.2.6" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Windows.Forms" />
Expand Down

0 comments on commit 185ded8

Please sign in to comment.