Skip to content

Commit 79499ce

Browse files
Ioseba Palopiosebyte
authored andcommitted
Minor fixes
1 parent feef75c commit 79499ce

File tree

6 files changed

+72
-69
lines changed

6 files changed

+72
-69
lines changed

FOCA/FormMain.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,13 @@ public void TreeViewProjectAfterSelect(object sender, TreeViewEventArgs e)
10171017
var h = (History)e.Node.Nodes["History"].Tag;
10181018
foreach (var hi in h.Items)
10191019
{
1020-
if (string.IsNullOrEmpty(hi.Author.Trim()))
1020+
if (String.IsNullOrWhiteSpace(hi.Author))
10211021
NewItemListView("Author", hi.Author, "History");
10221022

1023-
if (string.IsNullOrEmpty(hi.Comments.Trim()))
1023+
if (String.IsNullOrWhiteSpace(hi.Comments))
10241024
NewItemListView("Comments", hi.Comments, "History");
10251025

1026-
if (string.IsNullOrEmpty(hi.Path.Trim()))
1026+
if (String.IsNullOrWhiteSpace(hi.Path))
10271027
NewItemListView("Path", hi.Path, "History");
10281028
}
10291029
}
@@ -1499,16 +1499,16 @@ private void SetOldVersionNodes(TreeViewEventArgs e)
14991499

15001500
foreach (var vai in va.Items)
15011501
{
1502-
if (string.IsNullOrEmpty(vai.Author.Trim()))
1502+
if (String.IsNullOrEmpty(vai.Author))
15031503
NewItemListView("Author", vai.Author, valueOldVersion);
15041504

1505-
if (string.IsNullOrEmpty(vai.Comments.Trim()))
1505+
if (String.IsNullOrEmpty(vai.Comments))
15061506
NewItemListView("Comments", vai.Comments, valueOldVersion);
15071507

15081508
if (vai.SpecificDate)
15091509
NewItemListView("Date", vai.Date.ToString(), valueOldVersion);
15101510

1511-
if (string.IsNullOrEmpty(vai.Path.Trim()))
1511+
if (String.IsNullOrEmpty(vai.Path))
15121512
NewItemListView("Path", vai.Path, valueOldVersion);
15131513
}
15141514
}
@@ -1525,13 +1525,13 @@ private void SetHistoryNode(TreeViewEventArgs e)
15251525
var historyItems = (History)e.Node.Tag;
15261526
foreach (var hi in historyItems.Items)
15271527
{
1528-
if (hi.Author != null && hi.Author.Trim() != string.Empty)
1528+
if (!String.IsNullOrWhiteSpace(hi.Author))
15291529
NewItemListView("Author", hi.Author, historyValue);
15301530

1531-
if (hi.Comments != null && hi.Comments.Trim() != string.Empty)
1531+
if (!String.IsNullOrWhiteSpace(hi.Comments))
15321532
NewItemListView("Comments", hi.Comments, historyValue);
15331533

1534-
if (hi.Path != null && hi.Path.Trim() != string.Empty)
1534+
if (!String.IsNullOrWhiteSpace(hi.Path))
15351535
NewItemListView("Path", hi.Path, historyValue);
15361536
}
15371537
}
@@ -1548,16 +1548,16 @@ private void SetOldVersionNode(TreeViewEventArgs e)
15481548
var va = (OldVersions)e.Node.Tag;
15491549
foreach (var vai in va.Items)
15501550
{
1551-
if (vai.Author != null && vai.Author.Trim() != string.Empty)
1551+
if (!String.IsNullOrWhiteSpace(vai.Author))
15521552
NewItemListView("Author", vai.Author, oldVersionValue);
15531553

1554-
if (vai.Comments != null && vai.Comments.Trim() != string.Empty)
1554+
if (!String.IsNullOrWhiteSpace(vai.Comments))
15551555
NewItemListView("Comments", vai.Comments, oldVersionValue);
15561556

15571557
if (vai.SpecificDate)
15581558
NewItemListView("Date", vai.Date.ToString(), oldVersionValue);
15591559

1560-
if (vai.Path != null && vai.Path.Trim() != string.Empty)
1560+
if (!String.IsNullOrWhiteSpace(vai.Path))
15611561
NewItemListView("Path", vai.Path, oldVersionValue);
15621562
}
15631563
}
@@ -1568,10 +1568,10 @@ private void SetOldVersionNode(TreeViewEventArgs e)
15681568
/// <param name="e"></param>
15691569
private void SetOtherMetadataNode(TreeViewEventArgs e)
15701570
{
1571-
var otherMetaValue = "Other Metadata";
1571+
string otherMetaValue = "Other Metadata";
15721572

15731573
panelInformation.lvwInformation.Groups.Add("Other Metadata", "Other Metadata");
1574-
var metaDatadosValue = (MetaData)e.Node.Tag;
1574+
MetaData metaDatadosValue = (MetaData)e.Node.Tag;
15751575

15761576
if (metaDatadosValue.Applications != null && metaDatadosValue.Applications.Items.Count > 0)
15771577
foreach (var aplicacion in metaDatadosValue.Applications.Items)

FOCA/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.4.5.0")]
36-
[assembly: AssemblyFileVersion("3.4.5.0")]
35+
[assembly: AssemblyVersion("3.4.5.5")]
36+
[assembly: AssemblyFileVersion("3.4.5.5")]

MetadataExtractCore/Analysis/PathAnalysis.cs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
51
using MetadataExtractCore.Utilities;
2+
using System;
63

74
namespace MetadataExtractCore.Analysis
85
{
@@ -18,7 +15,7 @@ public static string ExtractUserFromPath(string pathValue)
1815
string resultUser;
1916

2017
if (GetUserFromPathValue(pathValue, @":\winnt\profiles\", out resultUser)) return resultUser;
21-
18+
2219
if (GetUserFromPathValue(pathValue, @":\documents and settings\", out resultUser)) return resultUser;
2320

2421
if (GetUserFromPathValue(pathValue, @":\dokumente und einstellungen\", out resultUser)) return resultUser;
@@ -68,14 +65,14 @@ public static bool IsValidPath(string pathValue)
6865
pathValue = pathValue.ToLower();
6966
if (!Functions.StringContainAnyLetter(pathValue))
7067
return false;
71-
68+
7269
if (pathValue.Length > 2 && char.IsLetter(pathValue[0]) && pathValue[1] == ':' && pathValue[2] == '\\')
7370
return true;
7471

7572
if (pathValue.StartsWith("\\\\") &&
7673
pathValue.Length > 2 && pathValue[2] != '\\')
7774
return true;
78-
75+
7976
if (pathValue.StartsWith("\\") &&
8077
pathValue.Length > 1 && pathValue[1] != '\\')
8178
return true;
@@ -109,7 +106,7 @@ public static string RemoveNamePath(string pathValue)
109106
return pathValue.Remove(pathValue.LastIndexOf('\\') + 1);
110107
if (pathValue.LastIndexOf('/') > pathValue.LastIndexOf('\\') && pathValue.LastIndexOf('/') < pathValue.Length - 1)
111108
return pathValue.Remove(pathValue.LastIndexOf('/') + 1);
112-
109+
113110
return pathValue;
114111
}
115112

@@ -120,19 +117,24 @@ public static string RemoveNamePath(string pathValue)
120117
/// <returns></returns>
121118
public static string CleanPath(string pathValue)
122119
{
123-
var uriValue = new Uri(pathValue);
124-
pathValue = uriValue.AbsoluteUri;
125-
126-
pathValue = RemoveNamePath(pathValue);
127-
128-
if (pathValue.IndexOf("file://") != -1)
129-
pathValue = pathValue.Substring(pathValue.IndexOf("file://") + 7, pathValue.Length - pathValue.IndexOf("file://") - 7);
130-
if (pathValue.IndexOf(':') != 2) return IsValidPath(pathValue) ? pathValue.Trim() : string.Empty;
120+
if (Uri.TryCreate(pathValue, UriKind.Absolute, out Uri uriValue))
121+
{
122+
pathValue = uriValue.AbsoluteUri;
123+
pathValue = RemoveNamePath(pathValue);
124+
if (pathValue.IndexOf("file://") != -1)
125+
pathValue = pathValue.Substring(pathValue.IndexOf("file://") + 7, pathValue.Length - pathValue.IndexOf("file://") - 7);
126+
if (pathValue.IndexOf(':') != 2)
127+
return IsValidPath(pathValue) ? pathValue.Trim() : String.Empty;
131128

132-
pathValue = pathValue.Replace('/', '\\');
133-
pathValue = pathValue.Substring(1, pathValue.Length - 1);
129+
pathValue = pathValue.Replace('/', '\\');
130+
pathValue = pathValue.Substring(1, pathValue.Length - 1);
134131

135-
return IsValidPath(pathValue) ? pathValue.Trim() : string.Empty;
132+
return IsValidPath(pathValue) ? pathValue.Trim() : String.Empty;
133+
}
134+
else
135+
{
136+
return String.Empty;
137+
}
136138
}
137139
}
138140
}

MetadataExtractCore/Metadata/EXIFDocument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public override void analyzeFile()
9797
}
9898
catch (Exception e)
9999
{
100-
System.Diagnostics.Debug.WriteLine("Error analizing EXIF metadata ({0})", e.ToString());
100+
System.Diagnostics.Debug.WriteLine($"Error analizing EXIF metadata ({e.ToString()})");
101101
}
102102
finally
103103
{

MetadataExtractCore/Metadata/Office972003.cs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
using MetadataExtractCore.Analysis;
2+
using MetadataExtractCore.Diagrams;
3+
using MetadataExtractCore.Utilities;
14
using System;
25
using System.Collections.Generic;
6+
using System.IO;
37
using System.Linq;
48
using System.Text;
5-
using System.IO;
69
using System.Text.RegularExpressions;
7-
using MetadataExtractCore.Utilities;
8-
using MetadataExtractCore.Analysis;
9-
using MetadataExtractCore.Diagrams;
1010

1111
namespace MetadataExtractCore.Metadata
1212
{
@@ -20,7 +20,7 @@ public Office972003()
2020
dicPictureEXIF = new SerializableDictionary<string, EXIFDocument>();
2121
}
2222

23-
public Office972003(Stream stm): this()
23+
public Office972003(Stream stm) : this()
2424
{
2525
this.stm = new MemoryStream();
2626
Functions.CopyStream(stm, this.stm);
@@ -189,7 +189,7 @@ private void GetPrintersInXls(OleDocument doc)
189189
return;
190190
BinaryReader br = new BinaryReader(Workbook);
191191
Workbook.Seek(0, SeekOrigin.Begin);
192-
while (Workbook.Position <= Workbook.Length - 2)
192+
while (Workbook.Position <= Workbook.Length - 4)
193193
{
194194
try
195195
{
@@ -200,14 +200,14 @@ private void GetPrintersInXls(OleDocument doc)
200200
if (Tipo == 0x4D)
201201
{
202202
long PosOri = Workbook.Position;
203-
if (br.ReadInt16() == 0)
203+
if (br.ReadInt16() == 0)
204204
{
205205
String PrinterName = Encoding.Unicode.GetString(br.ReadBytes(32 * 2)).Replace('\0', ' ');
206206
br.ReadInt16();
207207
br.ReadInt16();
208208
Int16 StructSize = br.ReadInt16();
209209
Int16 DriverSize = br.ReadInt16();
210-
210+
211211
if (DriverSize != 0)
212212
{
213213
Workbook.Seek(StructSize - (8 + 64), SeekOrigin.Current);
@@ -233,7 +233,7 @@ private void GetPrintersInXls(OleDocument doc)
233233
}
234234
}
235235

236-
private void GetHistory(OleDocument doc)
236+
private void GetHistory(OleDocument doc)
237237
{
238238
using (Stream WordDocument = doc.OpenStream("WordDocument"))
239239
{
@@ -323,29 +323,36 @@ private void GetOperatingSystem(OleDocument doc)
323323
case 4:
324324
switch (intLowVersion)
325325
{
326-
case 0: FoundMetaData.OperativeSystem = "Windows NT 4.0";
326+
case 0:
327+
FoundMetaData.OperativeSystem = "Windows NT 4.0";
327328
break;
328-
case 10: FoundMetaData.OperativeSystem = "Windows 98";
329+
case 10:
330+
FoundMetaData.OperativeSystem = "Windows 98";
329331
break;
330332
}
331333
break;
332334
case 5:
333335
switch (intLowVersion)
334336
{
335-
case 0: FoundMetaData.OperativeSystem = "Windows Server 2000";
337+
case 0:
338+
FoundMetaData.OperativeSystem = "Windows Server 2000";
336339
break;
337-
case 1: FoundMetaData.OperativeSystem = "Windows XP";
340+
case 1:
341+
FoundMetaData.OperativeSystem = "Windows XP";
338342
break;
339-
case 2: FoundMetaData.OperativeSystem = "Windows Server 2003";
343+
case 2:
344+
FoundMetaData.OperativeSystem = "Windows Server 2003";
340345
break;
341346
}
342347
break;
343348
case 6:
344349
switch (intLowVersion)
345350
{
346-
case 0: FoundMetaData.OperativeSystem = "Windows Vista";
351+
case 0:
352+
FoundMetaData.OperativeSystem = "Windows Vista";
347353
break;
348-
case 1: FoundMetaData.OperativeSystem = "Windows 7";
354+
case 1:
355+
FoundMetaData.OperativeSystem = "Windows 7";
349356
break;
350357
}
351358
break;
@@ -354,7 +361,8 @@ private void GetOperatingSystem(OleDocument doc)
354361

355362
private void GetPathPpt(OleDocument doc)
356363
{
357-
using (var WordDocument = doc.OpenStream("PowerPoint Document")) {
364+
using (var WordDocument = doc.OpenStream("PowerPoint Document"))
365+
{
358366
if (WordDocument == null)
359367
return;
360368
try
@@ -424,7 +432,7 @@ private void GetImagesDoc(OleDocument doc)
424432
}
425433
}
426434

427-
List<int> lstJPEG = Functions.SearchBytesInBytes(bufferPIC, new byte[] { 0xFF, 0xD8 });
435+
List<int> lstJPEG = Functions.SearchBytesInBytes(bufferPIC, new byte[] { 0xFF, 0xD8, 0xFF });
428436
if (lstJPEG.Count > 0)
429437
{
430438
using (MemoryStream msJPG = new MemoryStream(bufferPIC, lstJPEG[0], bufferPIC.Length - lstJPEG[0]))
@@ -468,17 +476,13 @@ private void GetImagesPpt(OleDocument doc)
468476
if (PICLength == 0 || stmPictures.Position + PICLength > stmPictures.Length) break;
469477
byte[] bufferPIC = brData.ReadBytes((int)PICLength);
470478
string strImageName = "Image" + ImagesFound++;
479+
471480
using (MemoryStream msJPG = new MemoryStream(bufferPIC, 0x11, bufferPIC.Length - 0x11))
472481
{
473482
EXIFDocument eDoc = new EXIFDocument(msJPG, ".jpg");
474-
483+
475484
eDoc.analyzeFile();
476485
eDoc.Close();
477-
if (eDoc.Thumbnail != null)
478-
lon += eDoc.Thumbnail.Length;
479-
cont++;
480-
System.Diagnostics.Debug.WriteLine(cont.ToString());
481-
System.Diagnostics.Debug.WriteLine(lon /(1024*1024) + " Megacas");
482486

483487
dicPictureEXIF.Add(strImageName, eDoc);
484488

@@ -496,9 +500,6 @@ private void GetImagesPpt(OleDocument doc)
496500
}
497501
}
498502

499-
static int cont = 0;
500-
static long lon = 0;
501-
502503
private void GetLinksBinary(OleDocument doc)
503504
{
504505
var pending = new List<Action>() {
@@ -566,9 +567,9 @@ private void GetLinksBinaryWorkbook(Stream document)
566567
continue;
567568

568569
string aux = link;
569-
aux = aux.Trim(new char[] { (char)18 });
570+
aux = aux.Trim(new char[] { (char)18 });
570571

571-
if (!link.EndsWith("/"))
572+
if (!link.EndsWith("/"))
572573
{
573574
int cuentaSlash = 0;
574575
for (int i = 0; i < aux.Length; i++)
@@ -603,7 +604,7 @@ private void GetLinksBinaryPowerPointDocument(Stream document)
603604
}
604605

605606

606-
private bool IsInterestingLink(string href)
607+
private bool IsInterestingLink(string href)
607608
{
608609
if (href != string.Empty)
609610
{
@@ -642,9 +643,9 @@ private bool IsInterestingLink(string href)
642643
return true;
643644
}
644645
}
645-
catch (UriFormatException)
646+
catch (UriFormatException)
646647
{
647-
if (!href.StartsWith("#"))
648+
if (!href.StartsWith("#"))
648649
{
649650
return true;
650651
}

MetadataExtractCore/Metadata/OpenOfficeDocument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private void analizeFileMeta(Stream stm)
277277
foreach (XmlNode xn in xnl)
278278
FoundPaths.AddUniqueItem(PathAnalysis.CleanPath(xn.Attributes.GetNamedItem("xlink:href").Value), true);
279279
xnl = doc.GetElementsByTagName("meta:document-statistic");
280-
if (xnl != null)
280+
if (xnl != null && xnl.Count > 0)
281281
{
282282
String estadisticas = string.Empty;
283283
if (xnl[0].Attributes.GetNamedItem("meta:table-count") != null)

0 commit comments

Comments
 (0)