mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
Camera de/serialization, folder management
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.chameleonvision.classabstraction.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class ProgramDirectoryUtilities
|
||||
{
|
||||
private static String getJarName()
|
||||
{
|
||||
return new File(ProgramDirectoryUtilities.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.getPath())
|
||||
.getName();
|
||||
}
|
||||
|
||||
private static boolean runningFromJAR()
|
||||
{
|
||||
String jarName = getJarName();
|
||||
return jarName.contains(".jar");
|
||||
}
|
||||
|
||||
public static String getProgramDirectory()
|
||||
{
|
||||
if (runningFromJAR())
|
||||
{
|
||||
return getCurrentJARDirectory();
|
||||
} else
|
||||
{
|
||||
return getCurrentProjectDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCurrentProjectDirectory()
|
||||
{
|
||||
return new File("").getAbsolutePath();
|
||||
}
|
||||
|
||||
private static String getCurrentJARDirectory()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new File(ProgramDirectoryUtilities.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParent();
|
||||
} catch (URISyntaxException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user