File: file.cpp

package info (click to toggle)
guymager 0.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 932 kB
  • ctags: 1,580
  • sloc: cpp: 8,522; ansic: 2,571; makefile: 49; sh: 23
file content (115 lines) | stat: -rw-r--r-- 3,556 bytes parent folder | download
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

// ****************************************************************************
//  Project:        GUYMAGER
// ****************************************************************************
//  Programmer:     Guy Voncken
//                  Police Grand-Ducale
//                  Service de Police Judiciaire
//                  Section Nouvelles Technologies
// ****************************************************************************
//  Module:         Everything related to file names, extension names, paths...
// ****************************************************************************


#include "common.h"

#include <QtCore>

#include "libewf.h"

#include "device.h"
#include "config.h"
//#include "dlgwait.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 F, QString &Str)
{
   QString SubFormat;
   switch (F)
   {
      case DD:
         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_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;
            default                   : CHK (ERROR_FILE_INVALID_EWF_FORMAT)
         }
         Str = QObject::tr("Expert Witness Format, sub-format %1") .arg(SubFormat);
         break;
      case AFF:
         Str = QObject::tr("Advanced forensic image");
         break;
      default:  CHK (ERROR_FILE_INVALID_FORMAT)
   }
   return NO_ERROR;
}

APIRET t_File::GetFormatExtension (t_Format F, QString *pExtWildCards, QString *pExtHumanReadable)
{
   QString Wild, Human;

   switch (F)
   {
      case DD:
         Wild = ".dd";
         Human = Wild;
         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_LINEN5 :
            case LIBEWF_FORMAT_FTK    : 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 AFF:
         Wild = ".aff";
         Human = Wild;
         break;
      default:  CHK (ERROR_FILE_INVALID_FORMAT)
   }

   if (pExtWildCards    ) *pExtWildCards     = Wild;
   if (pExtHumanReadable) *pExtHumanReadable = Human;

   return NO_ERROR;
}