1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
// ****************************************************************************
// Project: GUYMAGER
// ****************************************************************************
// Programmer: Guy Voncken
// Police Grand-Ducale
// Service de Police Judiciaire
// Section Nouvelles Technologies
// ****************************************************************************
// Module: Everything related to file names, extension names, paths...
// ****************************************************************************
// Copyright 2008, 2009, 2010, 2011 Guy Voncken
//
// This file is part of guymager.
//
// guymager is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// guymager is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with guymager. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
#include <QtCore>
#include "libewf.h"
#include "util.h"
#include "device.h"
#include "config.h"
const char *t_File::pExtensionInfo = ".info";
APIRET t_File::Init (void)
{
static bool Initialised=false;
if (Initialised)
{
CHK_EXIT (ERROR_FILE_ONLY_CAN_BE_INSTANTIATED_ONCE)
}
else
{
CHK_EXIT (TOOL_ERROR_REGISTER_CODE (ERROR_FILE_ONLY_CAN_BE_INSTANTIATED_ONCE))
CHK_EXIT (TOOL_ERROR_REGISTER_CODE (ERROR_FILE_INVALID_FORMAT))
CHK_EXIT (TOOL_ERROR_REGISTER_CODE (ERROR_FILE_INVALID_EWF_FORMAT))
Initialised = true;
}
return NO_ERROR;
}
APIRET t_File::GetFormatDescription (t_Format Format, bool Clone, int DdSplitDecimals, QString &Str)
{
QString SubFormat;
switch (Format)
{
case DD:
if (Clone) Str = QObject::tr("Creation of a clone");
else if (DdSplitDecimals) Str = QObject::tr("Linux split dd raw image");
else Str = QObject::tr("Linux dd raw image");
break;
case EWF:
switch (CONFIG(EwfFormat))
{
case LIBEWF_FORMAT_ENCASE1: SubFormat="Encase1" ; break;
case LIBEWF_FORMAT_ENCASE2: SubFormat="Encase2" ; break;
case LIBEWF_FORMAT_ENCASE3: SubFormat="Encase3" ; break;
case LIBEWF_FORMAT_ENCASE4: SubFormat="Encase4" ; break;
case LIBEWF_FORMAT_ENCASE5: SubFormat="Encase5" ; break;
case LIBEWF_FORMAT_ENCASE6: SubFormat="Encase6" ; break;
case LIBEWF_FORMAT_FTK : SubFormat="FTK" ; break;
case LIBEWF_FORMAT_SMART : SubFormat="Smart" ; break;
case LIBEWF_FORMAT_LVF : SubFormat="LVF" ; break;
case LIBEWF_FORMAT_LINEN5 : SubFormat="Linen5" ; break;
case AEWF : SubFormat="Guymager"; break;
default : CHK (ERROR_FILE_INVALID_EWF_FORMAT)
}
Str = QObject::tr("Expert Witness Format, sub-format %1") .arg(SubFormat);
break;
case AAFF:
Str = QObject::tr("Advanced forensic image");
break;
default: CHK (ERROR_FILE_INVALID_FORMAT)
}
return NO_ERROR;
}
APIRET t_File::GetFormatExtension (t_Format Format, bool Clone, int DdSplitDecimals, QString *pExtWildCards, QString *pExtHumanReadable)
{
QString Wild, Human;
switch (Format)
{
case DD:
if (!Clone)
{
if (DdSplitDecimals)
{
Human = Wild = ".";
while (DdSplitDecimals--)
{
Human += "x";
Wild += "?";
}
}
else
{
Human = Wild = ".dd";
}
}
break;
case EWF:
switch (CONFIG(EwfFormat))
{
case LIBEWF_FORMAT_ENCASE1:
case LIBEWF_FORMAT_ENCASE2:
case LIBEWF_FORMAT_ENCASE3:
case LIBEWF_FORMAT_ENCASE4:
case LIBEWF_FORMAT_ENCASE5:
case LIBEWF_FORMAT_ENCASE6:
case LIBEWF_FORMAT_LINEN5 :
case LIBEWF_FORMAT_FTK :
case AEWF : Wild=".E??"; Human=".Exx"; break;
case LIBEWF_FORMAT_SMART : Wild=".s??"; Human=".sxx"; break;
case LIBEWF_FORMAT_LVF : Wild=".l??"; Human=".lxx"; break;
default : CHK (ERROR_FILE_INVALID_EWF_FORMAT)
}
break;
case AAFF:
Wild = ".aff";
Human = Wild;
break;
default: CHK (ERROR_FILE_INVALID_FORMAT)
}
if (pExtWildCards ) *pExtWildCards = Wild;
if (pExtHumanReadable) *pExtHumanReadable = Human;
return NO_ERROR;
}
int t_File::GetDdSplitNrDecimals (t_uint64 DeviceSize, t_uint64 SplitFileSize)
{
int Decimals=0;
if (SplitFileSize)
{
Decimals = UtilCalcDecimals (1 + DeviceSize / SplitFileSize);
Decimals = GETMAX (Decimals, 3);
}
return Decimals;
}
APIRET t_File::GetFormatDescription (t_pDevice pDevice, QString &Str)
{
CHK (GetFormatDescription (pDevice->Acquisition.Format,
pDevice->Acquisition.Clone,
GetDdSplitNrDecimals (pDevice->Size, pDevice->Acquisition.SplitFileSize),
Str))
return NO_ERROR;
}
APIRET t_File::GetFormatExtension (t_pDevice pDevice, QString *pExtWildCards, QString *pExtHumanReadable)
{
CHK (GetFormatExtension (pDevice->Acquisition.Format,
pDevice->Acquisition.Clone,
GetDdSplitNrDecimals (pDevice->Size, pDevice->Acquisition.SplitFileSize),
pExtWildCards, pExtHumanReadable))
return NO_ERROR;
}
|