Skip to content

Commit

Permalink
Некоторые исправления в коде
Browse files Browse the repository at this point in the history
  • Loading branch information
parshikov committed May 6, 2016
1 parent e4f7157 commit 3095b6d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions FileMatchFinder/Classes/Torrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public bool CheckHash(int index, FileInfo fileOnDisk, bool checkFirstOnly)
fs.Read(piece, 0, this.PieceLength);
fileHash = Encoding.GetEncoding(437).GetString(sha1.ComputeHash(piece)).ToCharArray();


for (int i = 0; i < fileHash.Length; i++)
if (fileHash[i] != hashInTorrent[i])
return false;
Expand Down
5 changes: 3 additions & 2 deletions FileMatchFinder/Classes/TorrentReader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Text;
using BencodeLibrary;
using System.IO;

namespace FilesMatchFinder
{
Expand Down Expand Up @@ -33,7 +34,7 @@ public static Torrent ReadTorrent(string filename)
string fullPath = name;
foreach (BString partOfPath in filePaths)
{
fullPath += @"\" + partOfPath.Value;
fullPath += Path.PathSeparator + partOfPath.Value;
}
files.Add(new LostFile(fullPath, length, begin));

Expand All @@ -45,7 +46,7 @@ public static Torrent ReadTorrent(string filename)
long Length = ((BInt)fileInfo["length"]).Value;
files.Add(new LostFile(name, Length, 0));
}

return new Torrent(name, files, pieceLength, pieces, filename);
}
}
Expand Down
2 changes: 1 addition & 1 deletion FileMatchFinder/Classes/TreeWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void FindFiles(Torrent torrent, List<FileInfo> files, string desti

// Все проверки пройдены. перед нами искомый файл
// Перемещаем его
FileInfo fileToMove = new FileInfo(destinationPath + @"\" + fileInTorrent.Name);
FileInfo fileToMove = new FileInfo(destinationPath + Path.PathSeparator + fileInTorrent.Name);

if (!Directory.Exists(fileToMove.DirectoryName))
Directory.CreateDirectory(fileToMove.DirectoryName);
Expand Down

0 comments on commit 3095b6d

Please sign in to comment.