-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lzw.homework3 #8
base: main
Are you sure you want to change the base?
Conversation
Homework3/LZW/LZW/Bor.cs
Outdated
/// <summary> | ||
/// A class representing the bor data structure | ||
/// </summary> | ||
public class Bor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Он Trie
Homework3/LZW/LZW/Bor.cs
Outdated
public int GetCode() | ||
{ | ||
return currentNode.Code; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public int GetCode() | |
{ | |
return currentNode.Code; | |
} | |
public int GetCode() | |
=> currentNode.Code; |
Homework3/LZW/LZW/Bor.cs
Outdated
/// <summary> | ||
/// Function to add a byte | ||
/// </summary> | ||
/// <param name="byteToAdd"> byte to add </param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <param name="byteToAdd"> byte to add </param> | |
/// <param name="byteToAdd"> Byte to add </param> |
Homework3/LZW/LZW/LZW.cs
Outdated
{ | ||
|
||
string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | |
string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress); | |
{ | |
string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress); |
После открывающей фигурной скобки пустая строка не ставится
using FileStream fs = new(fileName, FileMode.Create); | ||
|
||
// Reading all bytes from a file | ||
var stringToConvert = File.ReadAllBytes(pathToFileToCompress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вообще, может быть плохой идеей читать файл в память целиком. Файлы бывают большие. Тем более что LZW может работать побайтово. Но это можно не править, для учебных целей вполне ок.
Homework3/LZW/LZW/Solution.cs
Outdated
{ | ||
if (args.Length != 2) | ||
{ | ||
throw new FileNotFoundException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не, а кто его поймает, если исключение бросается прямо из Main- а? Тут надо вежливо поругаться и рассказать, какие параметры программа ожидает.
Homework3/LZW/LZW/Solution.cs
Outdated
if (args[1] == "-u") | ||
{ | ||
LZW.DecompressFile(pathToFile); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А если не -c и не -u, то надо что-то сказать пользователю
Homework3/LZW/LZWTest/BorTest.cs
Outdated
|
||
public class BorTest | ||
{ | ||
Bor bor = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bor bor = new(); | |
private Bor bor = new(); |
Homework3/LZW/LZWTest/LZWTest.cs
Outdated
var firstString = File.ReadAllBytes(filename); | ||
var secondString = File.ReadAllBytes("..//..//..//Test"); | ||
Assert.AreEqual(firstString, secondString); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
На одном файле работает. А на пустом, на текстовом/бинарном?
Homework3/LZW/LZW/LZW.cs
Outdated
{ | ||
|
||
string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress); | ||
fileName = $"{pathToFileToCompress}..//..//{fileName}.zipped"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так мы теряем расширение файла в процессе запаковки/распаковки, что не очень.
Added comments Fixed a problem with file extension loss
No description provided.