-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
79 lines (73 loc) · 2.43 KB
/
Program.cs
File metadata and controls
79 lines (73 loc) · 2.43 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using jpeg2000_decoder.IO;
namespace jpeg2000_decoder
{
public class Logger
{
public enum Severity
{
Error,
Warning,
Debug
}
public static Severity MaxSeverity = Severity.Debug;
public static void Log(Severity severity, string message)
{
if(severity > MaxSeverity)
return;
switch (severity)
{
case Severity.Error: Console.ForegroundColor = ConsoleColor.Red; break;
case Severity.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break;
default: break;
}
System.Console.WriteLine(message);
Console.ResetColor();
}
public static void Error(string message)
{
Log(Severity.Error, message);
}
public static void Warning(string message)
{
Log(Severity.Warning, message);
}
public static void Debug(string message)
{
Log(Severity.Debug, message);
}
}
class Program
{
static void Main(string[] args)
{
Console.Clear();
if(args.Length == 0)
{
Logger.Error("No input file provided.");
return;
}
var inputFileName = args[0];
if(!File.Exists(inputFileName))
{
Logger.Error($@"Input file doesn't exist.
Filename provided: {inputFileName}");
return;
}
Logger.Debug($"Processing file: {inputFileName}");
try
{
var inputFile = File.OpenRead(inputFileName);
var decoder = new Decoder(new Util.ParameterList());
var randomAccessFile = new RandomAccessFile(inputFile);
//var decoded = decoder.Decode(randomAccessFile);
decoder.Decode(randomAccessFile);
}
catch(Exception e) {
Logger.Error($"Problem reading input file.\nException: {e.Message}");
}
}
}
}