updates to remove additional photorec

This commit is contained in:
Greg DiCristofaro 2020-06-12 10:30:32 -04:00
parent 51421996d8
commit 820dfc6caa
2 changed files with 17 additions and 15 deletions

View File

@ -81,6 +81,8 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
static final boolean DEFAULT_CONFIG_KEEP_CORRUPTED_FILES = false; static final boolean DEFAULT_CONFIG_KEEP_CORRUPTED_FILES = false;
private static final String PHOTOREC_DIRECTORY = "photorec_exec"; //NON-NLS private static final String PHOTOREC_DIRECTORY = "photorec_exec"; //NON-NLS
private static final String X64_DIR = "64-bit";
private static final String X86_DIR = "32-bit";
private static final String PHOTOREC_EXECUTABLE = "photorec_win.exe"; //NON-NLS private static final String PHOTOREC_EXECUTABLE = "photorec_win.exe"; //NON-NLS
private static final String PHOTOREC_LINUX_EXECUTABLE = "photorec"; private static final String PHOTOREC_LINUX_EXECUTABLE = "photorec";
private static final String PHOTOREC_RESULTS_BASE = "results"; //NON-NLS private static final String PHOTOREC_RESULTS_BASE = "results"; //NON-NLS
@ -454,6 +456,16 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
return path; return path;
} }
/**
* @return The correct copy of photorec for windows based on processor architecture.
*/
private static Path getWinExecutablePath() {
return Paths.get(
PHOTOREC_DIRECTORY,
PlatformUtil.is64BitOS() ? X64_DIR : X86_DIR,
PHOTOREC_EXECUTABLE);
}
/** /**
* Finds and returns the path to the executable, if able. * Finds and returns the path to the executable, if able.
* *
@ -468,7 +480,7 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
Path execName; Path execName;
String photorec_linux_directory = "/usr/bin"; String photorec_linux_directory = "/usr/bin";
if (PlatformUtil.isWindowsOS()) { if (PlatformUtil.isWindowsOS()) {
execName = Paths.get(PHOTOREC_DIRECTORY, PHOTOREC_EXECUTABLE); execName = getWinExecutablePath();
exeFile = InstalledFileLocator.getDefault().locate(execName.toString(), PhotoRecCarverFileIngestModule.class.getPackage().getName(), false); exeFile = InstalledFileLocator.getDefault().locate(execName.toString(), PhotoRecCarverFileIngestModule.class.getPackage().getName(), false);
} else { } else {
File usrBin = new File("/usr/bin/photorec"); File usrBin = new File("/usr/bin/photorec");

View File

@ -3,13 +3,6 @@
<!-- ADVANCED INSTALLER TARGETS --> <!-- ADVANCED INSTALLER TARGETS -->
<target name="build-installer-windows" depends="getProps,init-advanced-installer" <target name="build-installer-windows" depends="getProps,init-advanced-installer"
description="Makes an installer from the opened ZIP file"> description="Makes an installer from the opened ZIP file">
<!-- the path on disk for photorec files -->
<var name="photorec-inst-path" value="${inst-path}\${app.name}\photorec_exec"/>
<!-- the destination in installer for photorec relative to APPDATA -->
<var name="photorec-path" value="${app.name}\photorec_exec"/>
<antcall target="run-advanced-installer-32" inheritAll="true" /> <antcall target="run-advanced-installer-32" inheritAll="true" />
<antcall target="run-advanced-installer-64" inheritAll="true" /> <antcall target="run-advanced-installer-64" inheritAll="true" />
</target> </target>
@ -117,8 +110,7 @@
<var name="aut-bin-name" value="${app.name}.exe"/> <var name="aut-bin-name" value="${app.name}.exe"/>
<var name="gstreamer-path-todelete" value="${app.name}\gstreamer\1.0\x86_64"/> <var name="gstreamer-path-todelete" value="${app.name}\gstreamer\1.0\x86_64"/>
<var name="photorec-path-todelete" value="${app.name}\photorec_exec\64-bit"/>
<var name="photorec-path-toadd" value="${photorec-inst-path}\32-bit"/>
<var name="jvm.max.mem" value="512m" /> <var name="jvm.max.mem" value="512m" />
@ -145,8 +137,7 @@
<var name="aut-bin-name-todelete" value="${app.name}.exe"/> <var name="aut-bin-name-todelete" value="${app.name}.exe"/>
<var name="gstreamer-path-todelete" value="${app.name}\gstreamer\1.0\x86"/> <var name="gstreamer-path-todelete" value="${app.name}\gstreamer\1.0\x86"/>
<var name="photorec-path-todelete" value="${app.name}\photorec_exec\32-bit"/>
<var name="photorec-path-toadd" value="${photorec-inst-path}\64-bit"/>
<var name="jvm.max.mem" value="4G"/> <var name="jvm.max.mem" value="4G"/>
@ -207,10 +198,9 @@
<arg line="/edit ${aip-path} /DelFolder APPDIR\${gstreamer-path-todelete}"/> <arg line="/edit ${aip-path} /DelFolder APPDIR\${gstreamer-path-todelete}"/>
</exec> </exec>
<echo message="Using photorec with correct processor architecture..."/> <echo message="Removing extra PhotoRec binaries..."/>
<exec executable="${ai-exe-path}"> <exec executable="${ai-exe-path}">
<arg line="/edit ${aip-path} /DelFolder APPDIR\${photorec-path}"/> <arg line="/edit ${aip-path} /DelFolder APPDIR\${photorec-path-todelete}"/>
<arg line="/edit ${aip-path} /AddFolder APPDIR\${photorec-path} ${photorec-path-toadd}"/>
</exec> </exec>
</target> </target>