-
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 branch information
bob
committed
Oct 28, 2022
1 parent
5984578
commit 84febae
Showing
5 changed files
with
166 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
bin | ||
obj | ||
*.exe | ||
*.suo | ||
*.user | ||
*.dll | ||
*.pdb | ||
.git | ||
.vs | ||
*.log | ||
*.log.doc |
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,14 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("adb2tgz")] | ||
[assembly: AssemblyDescription("Converts Android ADB backup to TGZ archive type")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("JGhost")] | ||
[assembly: AssemblyProduct("adb2tgz")] | ||
[assembly: AssemblyCopyright("© 2015-2022 JGHost")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: ComVisible(false)] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,65 @@ | ||
using System; | ||
using System.IO; | ||
|
||
static class Program { | ||
|
||
static int Main(string[] args) { | ||
try { | ||
|
||
Console.WriteLine("Converts Android adb backup file to tgz archive type"); | ||
if (args.Length > 0) { | ||
if (File.Exists(args[0])) { | ||
Console.WriteLine("using file " + args[0]); | ||
|
||
FileStream fs = new FileStream(args[0], FileMode.Open, FileAccess.ReadWrite); | ||
byte[] buffer = new byte[8] { 0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
byte[] buffer1 = new byte[1024 * 1024 * 10]; | ||
fs.Read(buffer1, 0, 8); | ||
//Avoid corrupting a file that is already converted | ||
if (Compare(buffer, buffer1)) { | ||
Console.WriteLine("Selected file is already a tgz type. it might have been converted before"); | ||
return 1; | ||
} | ||
|
||
|
||
fs.Position = 0; | ||
fs.Write(buffer, 0, 8); | ||
long size = fs.Length; | ||
fs.Position = 24; | ||
int notification = 10; | ||
while (fs.Position < fs.Length) { | ||
fs.Read(buffer1, 0, buffer1.Length); | ||
fs.Position = fs.Position - buffer1.Length - 16; | ||
fs.Write(buffer1, 0, buffer1.Length); | ||
fs.Position = fs.Position + 16; | ||
notification--; | ||
if (notification < 1) { | ||
Console.WriteLine(" " + ((fs.Position / (decimal) size) * 100).ToString("0") + "%"); | ||
} | ||
} | ||
|
||
fs.Flush(); | ||
fs.Close(); | ||
Console.WriteLine(" Renaming adb file to tgz"); | ||
File.Move(args[0], args[0].Replace(Path.GetExtension(args[0]), ".tgz")); | ||
} | ||
} else { | ||
Console.WriteLine("No backup file selected, drag your backup file on executable to convert it to tar file"); | ||
} | ||
} catch (Exception ex) { | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
|
||
Console.WriteLine("Complete. Press a key to exit"); | ||
Console.ReadKey(); | ||
return 0; | ||
} | ||
|
||
private static bool Compare(byte[] buffer, byte[] buffer1) { | ||
for (int i = 0;i < buffer.Length;i++) { | ||
if (buffer[i] != buffer1[i]) | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
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,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{60BAFF0C-D983-4F68-9593-3CEC58D18DCC}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>adb2tgz</RootNamespace> | ||
<AssemblyName>adb2tgz</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>.\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>.\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.cs" /> | ||
<Compile Include="Program.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30523.141 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "adb2tgz", "adb2tgz.csproj", "{60BAFF0C-D983-4F68-9593-3CEC58D18DCC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{60BAFF0C-D983-4F68-9593-3CEC58D18DCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{60BAFF0C-D983-4F68-9593-3CEC58D18DCC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{60BAFF0C-D983-4F68-9593-3CEC58D18DCC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{60BAFF0C-D983-4F68-9593-3CEC58D18DCC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {FA8907BD-5A91-45B5-A80F-E57D9D09E599} | ||
EndGlobalSection | ||
EndGlobal |