Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion hw_13/.idea/modules/hw_13_main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified hw_14/FtpServer.jar
100755 → 100644
Binary file not shown.
Empty file added hw_14/FtpServer_old.jar
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void close() throws IOException {
*/
@NotNull
List<Pair<String, Boolean>> list(@NotNull Path path) throws IOException {
String command = "list " + path.toAbsolutePath().toString();
dataOutputStream.writeUTF(command);
dataOutputStream.writeInt(1);
dataOutputStream.writeUTF(path.toAbsolutePath().toString());
dataOutputStream.flush();
int sizeOfList = dataInputStream.readInt();
List<Pair<String, Boolean>> listOfFiles = new LinkedList<>();
Expand All @@ -94,11 +94,14 @@ List<Pair<String, Boolean>> list(@NotNull Path path) throws IOException {
* @throws IOException if error occurred during downloading and saving the file.
*/
void download(@NotNull Path pathToFile, @NotNull Path saveFilePath) throws IOException {
String command = "get " + pathToFile.toAbsolutePath().toString();
dataOutputStream.writeUTF(command);
dataOutputStream.writeInt(2);
dataOutputStream.writeUTF(pathToFile.toAbsolutePath().toString());
dataOutputStream.flush();
long sizeOfFile = dataInputStream.readLong();
OutputStream fileWriter = Files.newOutputStream(Files.createFile(saveFilePath));
if (!saveFilePath.toFile().exists()) {
Files.createFile(saveFilePath);
}
OutputStream fileWriter = Files.newOutputStream(saveFilePath);
byte[] buffer = new byte[2048];
for (long i = 0; i < sizeOfFile;) {
int numberOfReadBytes = dataInputStream.read(buffer);
Expand Down