diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-23 10:46:52 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-23 10:46:52 -0800 |
| commit | a18336fa1899a9f53b161a60e766695007c49a7b (patch) | |
| tree | f464c0475ea49e3714df86d69508644adcf2e98a /java/src/com/zerotier/one/DataStore.java | |
| parent | 1e4a40e77205b028d799f7112127f3f2f107117e (diff) | |
| parent | 764dd1c3d94527c0870a913ac314b3b17eaea282 (diff) | |
| download | infinitytier-a18336fa1899a9f53b161a60e766695007c49a7b.tar.gz infinitytier-a18336fa1899a9f53b161a60e766695007c49a7b.zip | |
MERGE current "dev" into "netcon" -- should not affect netcon itself but will retest -- brings ZeroTier core up to 1.1.0
Diffstat (limited to 'java/src/com/zerotier/one/DataStore.java')
| -rw-r--r-- | java/src/com/zerotier/one/DataStore.java | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/java/src/com/zerotier/one/DataStore.java b/java/src/com/zerotier/one/DataStore.java deleted file mode 100644 index d15b2d3d..00000000 --- a/java/src/com/zerotier/one/DataStore.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.zerotier.one; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import com.zerotier.sdk.DataStoreGetListener; -import com.zerotier.sdk.DataStorePutListener; - -public class DataStore implements DataStoreGetListener, DataStorePutListener { - - private DataStoreFileProvider _provider; - - public DataStore(DataStoreFileProvider provider) { - this._provider = provider; - } - - @Override - public int onDataStorePut(String name, byte[] buffer, boolean secure) { - System.out.println("Writing File: " + name); - try { - FileOutputStream fos = _provider.getOutputFileStream(name); - fos.write(buffer); - fos.close(); - return 0; - } catch (FileNotFoundException fnf) { - fnf.printStackTrace(); - return -1; - } catch (IOException io) { - io.printStackTrace(); - return -2; - } - } - - @Override - public int onDelete(String name) { - System.out.println("Deleting File: " + name); - try { - _provider.deleteFile(name); - return 0; - } catch (IOException ex) { - ex.printStackTrace(); - return -1; - } - } - - @Override - public long onDataStoreGet(String name, byte[] out_buffer, - long bufferIndex, long[] out_objectSize) { - System.out.println("Reading File: " + name); - try { - FileInputStream fin = _provider.getInputFileStream(name); - out_objectSize[0] = fin.getChannel().size(); - if(bufferIndex > 0) - { - fin.skip(bufferIndex); - } - int read = fin.read(out_buffer); - fin.close(); - return read; - } catch (FileNotFoundException fnf) { - // Can't read a file that doesn't exist! - out_objectSize[0] = 0; - return 0; - } catch (IOException io) { - io.printStackTrace(); - return -2; - } - } - - -} |
