-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from josephsmendoza/dlang
Dlang conversion
- Loading branch information
Showing
13 changed files
with
162 additions
and
444 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,123 @@ | ||
/+ dub.sdl: | ||
dependency "vibe-d" version="~>0.8.5" | ||
targetPath "bin/$PLATFORM/$ARCH" | ||
+/ | ||
|
||
import std.path; | ||
import std.stdio : writeln; | ||
import std.algorithm.searching : canFind; | ||
import std.process : environment; | ||
|
||
bool sys,user,silent,verbose; | ||
string installDir; | ||
|
||
int installTools(){ | ||
import std.zip,std.file,vibe.stream.operations,vibe.inet.urltransfer,std.conv : octal; | ||
|
||
version(Windows) string url="https://dl.google.com/android/repository/platform-tools-latest-windows.zip"; | ||
version(OSX) string url="https://dl.google.com/android/repository/platform-tools-latest-darwin.zip"; | ||
version(linux) string url="https://dl.google.com/android/repository/platform-tools-latest-linux.zip"; | ||
|
||
download(url, (scope data){ | ||
auto zip=new ZipArchive(data.readAll()); | ||
"Download complete".writeln(); | ||
foreach (x;zip.directory){ | ||
auto path=buildNormalizedPath(installDir,x.name[15 .. $]); | ||
if(x.compressedSize!=0){ | ||
if(!path.dirName.exists) path.dirName.mkdirRecurse(); | ||
if(path.exists) path.remove(); | ||
zip.expand(x); | ||
write(path, x.expandedData); | ||
setAttributes(path,octal!775); | ||
} else { | ||
try if(path.isFile) path.remove; | ||
catch (Exception e) path.mkdirRecurse; | ||
} | ||
} | ||
}); | ||
"Extraction complete".writeln(); | ||
return 0; | ||
} | ||
|
||
int installPath(){ | ||
string path=environment.get("PATH"); | ||
if(path.canFind(installDir)){ | ||
"Install folder is already in PATH".writeln; | ||
return 0; | ||
} | ||
|
||
version(Windows){ | ||
import std.windows.registry; | ||
Key env; | ||
if(user){ | ||
env=Registry.currentUser.getKey("Environment",REGSAM.KEY_ALL_ACCESS); | ||
} | ||
if(sys){ | ||
env=Registry.localMachine.getKey("SYSTEM").getKey("CurrentControlSet") | ||
.getKey("Control").getKey("Session Manager").getKey("Environment",REGSAM.KEY_ALL_ACCESS); | ||
} | ||
path=env.getValue("Path").value_SZ; | ||
path~=pathSeparator~installDir; | ||
env.setValue("Path",path); | ||
//import core.sys.windows.winuser; SendNotifyMessageW(HWND_BROADCAST,WM_SETTINGCHANGE,cast(ulong)null,cast(long)"Environment"); | ||
} else { | ||
import std.file : append; | ||
if(user) append("~/.profile".expandTilde,"\nexport PATH=$PATH"~pathSeparator~installDir); | ||
if(sys) append("/etc/profile","\nexport PATH=$PATH"~pathSeparator~installDir); | ||
} | ||
|
||
"Install folder was added to PATH".writeln(); | ||
"logout/login or reboot to coplete install".writeln(); | ||
return 0; | ||
} | ||
|
||
int install(){ | ||
if(user) "Installing for current user".writeln(); | ||
if(sys) "Installing for all users".writeln(); | ||
("Installing to " ~ installDir).writeln(); | ||
return installTools() + installPath(); | ||
} | ||
|
||
int main(string[] args){ | ||
|
||
import std.getopt : getopt,defaultGetoptPrinter; | ||
|
||
auto xargs=getopt(args, | ||
"all-users|a","Install for all users.",&sys, | ||
"user|u","Install for current user.",&user, | ||
//"silent|s","Silent standard output.",&silent, | ||
//"verbose|v","Verbose standard output.",&verbose, | ||
"install-dir|i","Install to specified directory",&installDir | ||
); | ||
|
||
if(installDir){ | ||
installDir=installDir.buildNormalizedPath.absolutePath; | ||
if(!sys && !user){ | ||
string allHome="~".expandTilde.dirName; | ||
if(!allHome.isRooted && installDir.canFind(allHome)) user=true; | ||
else sys=true; | ||
} | ||
return install(); | ||
} | ||
|
||
if(user || sys){ | ||
auto append=buildNormalizedPath("Android","SDK","platform-tools"); | ||
|
||
if(user){ | ||
version(Windows)installDir=buildNormalizedPath(environment.get("LocalAppData"),append); | ||
version(linux)installDir=buildNormalizedPath("~".expandTilde,append); | ||
version(OSX)installDir=buildNormalizedPath("~/Library".expandTilde,append); | ||
return install(); | ||
} | ||
|
||
if(sys){ | ||
version(Windows)installDir=buildNormalizedPath(environment.get("ProgramFiles"),append); | ||
version(linux)installDir=buildNormalizedPath("/opt",append); | ||
version(OSX)installDir=buildNormalizedPath("/Library",append); | ||
return install(); | ||
} | ||
} | ||
|
||
defaultGetoptPrinter("Download platform-tools and add to PATH.",xargs.options); | ||
return 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,4 @@ | ||
@echo off | ||
cd %~dp0 | ||
adbi.exe %* | ||
pause |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
gradle runtime | ||
ptiso create -z lzma -c crc32 -x stub ptse_cmd.stub -x runas admin -x mount_system_visible 0 -x process_visible 1 -x run_relative 1 -x use_stderr 1 -x run_exe bin/ADB-Installer.bat -x icon adb.ico ADB-Installer.exe build\image | ||
dub build --single adbi.d | ||
ptiso create -z lzma -c crc32 -x stub ptse_cmd.stub -x runas admin -x mount_system_visible 0 -x process_visible 1 -x run_relative 1 -x use_stderr 1 -x run_exe adbi.cmd -x icon adb.ico ADB-Installer.exe bin/windows/x86_64 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/+ dub.sdl | ||
sourceFiles "adbi.d" | ||
+/ |
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,30 @@ | ||
/+ dub.sdl: | ||
dependency "tkd" version="1.1.13" | ||
targetPath "bin/$PLATFORM/$ARCH" | ||
copyFiles \ | ||
"$TCLTK_PACKAGE_DIR/dist/$ARCH/tcl86t.dll" \ | ||
"$TCLTK_PACKAGE_DIR/dist/$ARCH/tk86t.dll" \ | ||
"$TCLTK_PACKAGE_DIR/dist/library" \ | ||
platform="windows" | ||
+/ | ||
|
||
import tkd.tkdapplication; | ||
|
||
class GUI : TkdApplication | ||
{ | ||
override protected void initInterface() | ||
{ | ||
auto frame = new Frame().pack(5); | ||
new Label(frame, "Select an install location").pack(0); | ||
auto searchLabel=new Label(frame,"Searching for pre-existing files...").pack(0); | ||
new Button(frame, "System").pack(0); | ||
new Button(frame, "User").pack(0); | ||
new Button(frame, "Mixed").pack(0); | ||
} | ||
} | ||
|
||
void main(string[] args) | ||
{ | ||
auto gui = new GUI(); | ||
gui.run(); | ||
} |
57 changes: 0 additions & 57 deletions
57
src/josephsmendoza/android/sdk/platformTools/installer/AVFixInstall.java
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
src/josephsmendoza/android/sdk/platformTools/installer/Common.java
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
src/josephsmendoza/android/sdk/platformTools/installer/FileInstall.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.