diff --git a/src/main/java/ru/redguy/tftpserver/IDataSource.java b/src/main/java/ru/redguy/tftpserver/IDataSource.java new file mode 100644 index 0000000..e711ac1 --- /dev/null +++ b/src/main/java/ru/redguy/tftpserver/IDataSource.java @@ -0,0 +1,5 @@ +package ru.redguy.tftpserver; + +public interface IDataSource { + public boolean isFileExists(String localPath); +} diff --git a/src/main/java/ru/redguy/tftpserver/datasource/FileSystem.java b/src/main/java/ru/redguy/tftpserver/datasource/FileSystem.java new file mode 100644 index 0000000..04d2d68 --- /dev/null +++ b/src/main/java/ru/redguy/tftpserver/datasource/FileSystem.java @@ -0,0 +1,31 @@ +package ru.redguy.tftpserver.datasource; + +import ru.redguy.tftpserver.IDataSource; + +import java.io.File; +import java.nio.file.Path; + +public class FileSystem implements IDataSource { + + String path; + + public FileSystem(File file) { + path = file.getAbsolutePath()+"/"; + } + + public FileSystem(Path path) { + this.path = path.toAbsolutePath().toString()+"/"; + } + + public FileSystem(String path) { + this.path = path; + if(!this.path.endsWith("/")) { + this.path = this.path+"/"; + } + } + + @Override + public boolean isFileExists(String localPath) { + return new File(this.path,localPath).exists(); + } +}