import android.content.OperationApplicationException;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Environment;
import android.os.RemoteException;
import android.util.Log;
return mContentProvider;
}
+ @Override
public Vector<OCFile> getDirectoryContent(OCFile f) {
if (f != null && f.isDirectory() && f.getFileId() != -1) {
Vector<OCFile> ret = new Vector<OCFile>();
return file;
}
+ @Override
public void removeFile(OCFile file, boolean removeLocalCopy) {
Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
if (getContentProvider() != null) {
if (file.isDown() && removeLocalCopy) {
new File(file.getStoragePath()).delete();
}
+ if (file.isDirectory() && removeLocalCopy) {
+ File f = new File(FileDownloader.getSavePath(mAccount.name) + file.getRemotePath());
+ if (f.exists() && f.isDirectory() && (f.list() == null || f.list().length == 0)) {
+ f.delete();
+ }
+ }
+ }
+
+ @Override
+ public void removeDirectory(OCFile dir, boolean removeDBData, boolean removeLocalContent) {
+ // TODO consider possible failures
+ if (dir != null && dir.isDirectory() && dir.getFileId() != -1) {
+ Vector<OCFile> children = getDirectoryContent(dir);
+ if (children != null) {
+ OCFile child = null;
+ for (int i=0; i<children.size(); i++) {
+ child = children.get(i);
+ if (child.isDirectory()) {
+ removeDirectory(child, removeDBData, removeLocalContent);
+ } else {
+ if (removeDBData) {
+ removeFile(child, removeLocalContent);
+ } else if (removeLocalContent) {
+ if (child.isDown()) {
+ new File(child.getStoragePath()).delete();
+ }
+ }
+ }
+ }
+ if (removeDBData) {
+ removeFile(dir, true);
+ }
+ }
+ }
}
}