Created
November 5, 2015 04:31
-
-
Save rdavisau/b66df9c99a4b11c5ceff to your computer and use it in GitHub Desktop.
Checks your iTunes folder for any .ipas that look like Xamarin apps
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
void Main() | |
{ | |
var myXamarinApps = | |
Directory | |
.EnumerateFiles(Path.Combine(Environment.GetEnvironmentVariable("HOMEPATH"), @"Music\iTunes\iTunes Media\Mobile Applications"), "*.ipa") | |
.Where(f=> ZipFile.Open(f, ZipArchiveMode.Read) | |
.GetRawEntries() | |
.Any(e=> e.FullName.Contains(".monotouch-"))); | |
foreach (var app in myXamarinApps) | |
Console.WriteLine(Path.GetFileNameWithoutExtension(app)); | |
} | |
// we need this because some apps contain non-windows-friendly filenames, and ZipArchive.Entries will throw | |
// http://www.codeproject.com/Tips/1007398/Avoid-Illegal-Characters-in-Path-error-in-ZipArchi | |
public static class ZipArchiveHelper | |
{ | |
private static FieldInfo _Entries; | |
private static MethodInfo _EnsureDirRead; | |
static ZipArchiveHelper() | |
{ | |
_Entries= typeof(ZipArchive).GetField("_entries",BindingFlags.NonPublic|BindingFlags.Instance); | |
_EnsureDirRead = typeof(ZipArchive).GetMethod("EnsureCentralDirectoryRead", BindingFlags.NonPublic | BindingFlags.Instance); | |
} | |
public static List<ZipArchiveEntry> GetRawEntries(this ZipArchive archive) | |
{ | |
try { _EnsureDirRead.Invoke(archive, null); } catch { } | |
return (List<ZipArchiveEntry>)_Entries.GetValue(archive); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment