Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Nov 29, 2024
0 parents commit 516a335
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,java
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,java

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,java

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

77 changes: 77 additions & 0 deletions Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
for (File folder : new File(System.getenv("HAXEPATH") + "/lib/").listFiles()) {
if (folder.isDirectory()) {
try {
String libPath = "C:/HaxeToolkit/haxe/lib/" + folder.getName();
Scanner s = new Scanner(new File(libPath + "/.current"));
String currentVersion = s.nextLine();
String formattedFolder = folder.getName().replace(',', '.');
System.out.println("Checking " + formattedFolder);
for (File libVersion : new File(libPath).listFiles()) {
if (libVersion.isDirectory()) {
if (!libVersion.getName().contains(currentVersion.replace('.', ','))) {
String strippedVersion = libVersion.getName().replace(libPath, "");
String formattedVersion = strippedVersion.replace(',', '.');
System.out
.println("\nFound unused version: " + formattedVersion);
System.out.println("Would you like to remove it? y/n");
if (System.console().readLine().toLowerCase().equals("y")) {
runCommand("haxelib", "remove", formattedFolder, formattedVersion);
} else {
System.out.println("Skipping.");
}

}
}
}
s.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}
}

/**
* Runs a system command
* I got this off a random website lol
*
* @see https://javapointers.com/java/java-core/how-to-run-a-command-using-java-in-linux-or-windows/
* @param command The command to run
*/
public static void runCommand(String... command) {
ProcessBuilder processBuilder = new ProcessBuilder().command(command);

try {
Process process = processBuilder.start();

// read the output
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String output = null;
while ((output = bufferedReader.readLine()) != null) {
System.out.println(output);
}

// wait for the process to complete
process.waitFor();

// close the resources
bufferedReader.close();
process.destroy();

} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}

0 comments on commit 516a335

Please sign in to comment.