Start creating FileSystem class
This commit is contained in:
parent
8dac1ac001
commit
630e76198e
5
src/main/java/ru/redguy/tftpserver/IDataSource.java
Normal file
5
src/main/java/ru/redguy/tftpserver/IDataSource.java
Normal file
@ -0,0 +1,5 @@
|
||||
package ru.redguy.tftpserver;
|
||||
|
||||
public interface IDataSource {
|
||||
public boolean isFileExists(String localPath);
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user