blob: 73c98a9e022a46974a86385f7b72595d8682a27a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package com.zerotier.one;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class JavaFileProvider implements DataStoreFileProvider {
private String _path;
public JavaFileProvider(String path) {
this._path = path;
}
@Override
public FileInputStream getInputFileStream(String name)
throws FileNotFoundException {
File f = new File(_path + File.pathSeparator + name);
return new FileInputStream(f);
}
@Override
public FileOutputStream getOutputFileStream(String name)
throws FileNotFoundException {
File f = new File(_path + File.pathSeparator + name);
return new FileOutputStream(f);
}
@Override
public void deleteFile(String name) throws IOException {
File f = new File(_path + File.pathSeparator + name);
boolean success = f.delete();
if(!success) {
throw new IOException("Unable to delete file: " + _path + File.pathSeparator + name);
}
}
}
|