Skip to content

Commit

Permalink
- Detect RenPy libarires that don't belong, drastically frees up giga…
Browse files Browse the repository at this point in the history
…bytes of space

- Detected nested game folders for Capcom (DMC Devil May Cry), previously ignored because program only checks first directory for valid directories.
- Delete .so bundles from game folders on windows.
  • Loading branch information
Andrew committed Jan 11, 2016
1 parent de5b063 commit dc3b4af
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
11 changes: 6 additions & 5 deletions SteamCleaner/SteamCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
<Resource Include="FodyWeavers.xml">
<SubType>Designer</SubType>
</Resource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.28.3\build\Fody.targets" Condition="Exists('..\packages\Fody.1.28.3\build\Fody.targets')" />
Expand All @@ -160,8 +162,7 @@
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.IO" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" />
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs">
<![CDATA[
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs"><![CDATA[
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
if (config == null) return true;
Expand All @@ -180,8 +181,8 @@ var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblie
foreach (var item in filesToCleanup)
File.Delete(item);
]]>
</Code></Task>
]]></Code>
</Task>
</UsingTask>
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
Expand Down
40 changes: 33 additions & 7 deletions SteamCleaner/Utilities/CleanerUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,43 @@ internal class CleanerUtilities
public static bool updateRedistributables = true;


private static List<string> DirectoryWalk(string sDir)
private static List<string> DetectRedistributablesWalk(string sDir)
{
var files = new List<string>();

var files = new List<string>();

foreach (var d in from d in Directory.GetDirectories(sDir)
let regex = new Regex("(.*)(directx|redist|miles)(.*)", RegexOptions.IgnoreCase)
let regex = new Regex("(.*)(directx|redist|miles|support)(.*)", RegexOptions.IgnoreCase)
let match = regex.Match(d)
where match.Success
select d)
{
files.AddRange(DirectoryWalk(d));
files.AddRange(DetectRedistributablesWalk(d));
files.AddRange(from f in Directory.GetFiles(d)
let filePathRegex = new Regex("(cab|exe|msi)", RegexOptions.IgnoreCase)
let filePathRegex = new Regex("(cab|exe|msi|so)", RegexOptions.IgnoreCase)
let fileMatch = filePathRegex.Match(f)
where fileMatch.Success
select f);
}
return files;
}


private static List<string> DetectRenPyRedistributables(string sDir)
{
var files = new List<string>();
var filters = new string[] { "darwin", "linux" };
foreach (var d in Directory.GetDirectories(sDir).Where(d => d.Contains("\\lib")))
{
files.AddRange(DetectRenPyRedistributables(d));
foreach (var filter in filters.Where(filter => d.ToLower().Contains(filter)))
{
files.AddRange(from f in Directory.GetFiles(d)
select f);
}
}
return files;
}

public static List<Redistributables> FindRedistributables()
{
if (cachedRedistributables != null && !updateRedistributables)
Expand All @@ -50,12 +67,21 @@ public static List<Redistributables> FindRedistributables()
}
var steamPaths = SteamUtilities.SteamPaths();
var crawlableDirs = steamPaths.Select(path => SteamUtilities.FixPath(path)).Where(appPath => Directory.Exists(appPath)).ToList();

var gameDirs =
crawlableDirs.Select(Directory.GetDirectories).SelectMany(directories => directories).ToList();
//Probably a better way to detect if some retarded publisher nested their package in a folder, but atm capcom is the only one i've seen do it.
foreach (var nestedGameFolder in gameDirs.ToList().Where(gameDir => gameDir.ToLower().Contains("capcom")).Select(gameDir => new DirectoryInfo(gameDir).GetDirectories()).SelectMany(nestedGameFolders => nestedGameFolders))
{
gameDirs.Add(nestedGameFolder.FullName);
}

var redistFiles = new List<string>();
foreach (var dir in gameDirs)
{
redistFiles.AddRange(DirectoryWalk(dir));
redistFiles.AddRange(DetectRedistributablesWalk(dir));
redistFiles.AddRange(DetectRenPyRedistributables(dir));

}
var cleanAbleFiles = redistFiles.Select(file => new Redistributables
{
Expand Down
2 changes: 2 additions & 0 deletions SteamCleaner/Utilities/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public static async void CheckForUpdates()
MessageTextBlock =
{
Text = "A new Steam Cleaner update is available, update now?"

}

};

var result = await DialogHost.Show(dialog);
Expand Down
2 changes: 1 addition & 1 deletion version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<steamcleaner>
<version>1.2</version>
<version>1.3</version>
<url>https://github.com/Codeusa/SteamCleaner/releases/latest</url>
</steamcleaner>

0 comments on commit dc3b4af

Please sign in to comment.