Skip to content

Commit 7cf33ec

Browse files
author
Guy Acosta
committed
Fixes #146, #147
1 parent 1af0ce4 commit 7cf33ec

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

AppInspector/Commands/AnalyzeCommand.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public class AnalyzeCommand : ICommand
2525

2626
public enum ExitCode
2727
{
28-
NoMatches = 0,
29-
MatchesFound = 1,
28+
Success = 0,
29+
NoMatches = 1,
3030
CriticalError = 2
3131
}
3232

33+
3334
IEnumerable<string> _srcfileList;
3435
AppProfile _appProfile;
3536
RuleProcessor _rulesProcessor;
@@ -267,11 +268,21 @@ public int Run()
267268
// Iterate through all files and process against rules
268269
foreach (string filename in _srcfileList)
269270
{
270-
ArchiveFileType archiveFileType = MiniMagic.DetectFileType(filename);
271+
ArchiveFileType archiveFileType;
272+
try //fix for #146
273+
{
274+
archiveFileType = MiniMagic.DetectFileType(filename);
275+
}
276+
catch (Exception e)
277+
{
278+
throw new OpException(ErrMsg.FormatString(ErrMsg.ID.ANALYZE_FILE_TYPE_OPEN, filename));
279+
}
280+
271281
if (archiveFileType == ArchiveFileType.UNKNOWN)//not a known zipped file type
272282
ProcessAsFile(filename);
273283
else
274-
UnZipAndProcess(filename,archiveFileType);
284+
UnZipAndProcess(filename, archiveFileType);
285+
275286
}
276287

277288
WriteOnce.General("\r"+ErrMsg.FormatString(ErrMsg.ID.ANALYZE_FILES_PROCESSED_PCNT, 100));
@@ -298,7 +309,7 @@ public int Run()
298309
}
299310

300311
return _appProfile.MatchList.Count() == 0 ? (int)ExitCode.NoMatches :
301-
(int)ExitCode.MatchesFound;
312+
(int)ExitCode.Success;
302313
}
303314

304315

AppInspector/ErrorMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public enum ID
2626
ANALYZE_COMPRESSED_FILESIZE_WARN,
2727
ANALYZE_COMPRESSED_PROCESSING,
2828
ANALYZE_COMPRESSED_ERROR,
29+
ANALYZE_FILE_TYPE_OPEN,
2930
ANALYZE_OUTPUT_FILE,
3031
ANALYZE_REPORTSIZE_WARN,
3132
CMD_PREPARING_REPORT,

AppInspector/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppInspector/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@
138138
<data name="ANALYZE_FILES_PROCESSED_PCNT" xml:space="preserve">
139139
<value>{0}% source files processed</value>
140140
</data>
141+
<data name="ANALYZE_FILE_TYPE_OPEN" xml:space="preserve">
142+
<value>Unable to determine file type. File open error for {0}</value>
143+
</data>
141144
<data name="ANALYZE_LANGUAGE_NOTFOUND" xml:space="preserve">
142145
<value>File skipped: Language not found for file {0}</value>
143146
</data>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"profiles": {
33
"ApplicationInspector": {
4-
"commandName": "Project",
5-
"commandLineArgs": "analyze -s c:\\temp\\main.cpp -b"
4+
"commandName": "Project"
65
}
76
}
87
}

0 commit comments

Comments
 (0)