Start creating FileSystem class

This commit is contained in:
Ilya 2020-10-16 10:11:57 +03:00
parent 8dac1ac001
commit 630e76198e
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,5 @@
package ru.redguy.tftpserver;
public interface IDataSource {
public boolean isFileExists(String localPath);
}

View File

@ -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();
}
}