Skip to content

Conversation

@MinyazevR
Copy link
Owner

No description provided.

/// <summary>
/// A class representing the bor data structure
/// </summary>
public class Bor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Он Trie

Comment on lines 28 to 31
public int GetCode()
{
return currentNode.Code;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public int GetCode()
{
return currentNode.Code;
}
public int GetCode()
=> currentNode.Code;

/// <summary>
/// Function to add a byte
/// </summary>
/// <param name="byteToAdd"> byte to add </param>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <param name="byteToAdd"> byte to add </param>
/// <param name="byteToAdd"> Byte to add </param>

Comment on lines 35 to 37
{

string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще, может быть плохой идеей читать файл в память целиком. Файлы бывают большие. Тем более что LZW может работать побайтово. Но это можно не править, для учебных целей вполне ок.

{
if (args.Length != 2)
{
throw new FileNotFoundException();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, а кто его поймает, если исключение бросается прямо из Main- а? Тут надо вежливо поругаться и рассказать, какие параметры программа ожидает.

if (args[1] == "-u")
{
LZW.DecompressFile(pathToFile);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если не -c и не -u, то надо что-то сказать пользователю


public class BorTest
{
Bor bor = new();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Bor bor = new();
private Bor bor = new();

var firstString = File.ReadAllBytes(filename);
var secondString = File.ReadAllBytes("..//..//..//Test");
Assert.AreEqual(firstString, secondString);
}

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);
fileName = $"{pathToFileToCompress}..//..//{fileName}.zipped";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так мы теряем расширение файла в процессе запаковки/распаковки, что не очень.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants