|
@@ -18,25 +18,29 @@ public class DataStore implements DataStoreGetListener, DataStorePutListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int onDataStorePut(String name, byte[] buffer, boolean secure) {
|
|
public int onDataStorePut(String name, byte[] buffer, boolean secure) {
|
|
|
|
+ System.out.println("Writing File: " + name);
|
|
try {
|
|
try {
|
|
FileOutputStream fos = _provider.getOutputFileStream(name);
|
|
FileOutputStream fos = _provider.getOutputFileStream(name);
|
|
fos.write(buffer);
|
|
fos.write(buffer);
|
|
fos.close();
|
|
fos.close();
|
|
return buffer.length;
|
|
return buffer.length;
|
|
} catch (FileNotFoundException fnf) {
|
|
} catch (FileNotFoundException fnf) {
|
|
-
|
|
|
|
|
|
+ fnf.printStackTrace();
|
|
|
|
+ return -1;
|
|
} catch (IOException io) {
|
|
} catch (IOException io) {
|
|
-
|
|
|
|
|
|
+ io.printStackTrace();
|
|
|
|
+ return -2;
|
|
}
|
|
}
|
|
- return 0;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int onDelete(String name) {
|
|
public int onDelete(String name) {
|
|
|
|
+ System.out.println("Deleting File: " + name);
|
|
try {
|
|
try {
|
|
_provider.deleteFile(name);
|
|
_provider.deleteFile(name);
|
|
return 0;
|
|
return 0;
|
|
} catch (IOException ex) {
|
|
} catch (IOException ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -44,6 +48,7 @@ public class DataStore implements DataStoreGetListener, DataStorePutListener {
|
|
@Override
|
|
@Override
|
|
public long onDataStoreGet(String name, byte[] out_buffer,
|
|
public long onDataStoreGet(String name, byte[] out_buffer,
|
|
long bufferIndex, long[] out_objectSize) {
|
|
long bufferIndex, long[] out_objectSize) {
|
|
|
|
+ System.out.println("Reading File: " + name);
|
|
try {
|
|
try {
|
|
FileInputStream fin = _provider.getInputFileStream(name);
|
|
FileInputStream fin = _provider.getInputFileStream(name);
|
|
out_objectSize[0] = fin.getChannel().size();
|
|
out_objectSize[0] = fin.getChannel().size();
|
|
@@ -55,8 +60,11 @@ public class DataStore implements DataStoreGetListener, DataStorePutListener {
|
|
fin.close();
|
|
fin.close();
|
|
return read;
|
|
return read;
|
|
} catch (FileNotFoundException fnf) {
|
|
} catch (FileNotFoundException fnf) {
|
|
- return -1;
|
|
|
|
|
|
+ // Can't read a file that doesn't exist!
|
|
|
|
+ out_objectSize[0] = 0;
|
|
|
|
+ return 0;
|
|
} catch (IOException io) {
|
|
} catch (IOException io) {
|
|
|
|
+ io.printStackTrace();
|
|
return -2;
|
|
return -2;
|
|
}
|
|
}
|
|
}
|
|
}
|