AbstractStoragePointProvider.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Nextcloud Android client application
  3. *
  4. * @author Bartosz Przybylski
  5. * Copyright (C) 2016 Nextcloud
  6. * Copyright (C) 2016 Bartosz Przybylski
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. package com.owncloud.android.datastorage.providers;
  22. import com.owncloud.android.datastorage.StoragePoint;
  23. import java.io.File;
  24. import java.util.Vector;
  25. /**
  26. * @author Bartosz Przybylski
  27. */
  28. abstract class AbstractStoragePointProvider implements IStoragePointProvider {
  29. boolean canBeAddedToAvailableList(Vector<StoragePoint> currentList, String path) {
  30. if (path == null) {
  31. return false;
  32. }
  33. for (StoragePoint storage : currentList) {
  34. if (storage.getPath().equals(path)) {
  35. return false;
  36. }
  37. }
  38. File f = new File(path);
  39. return f.exists() && f.isDirectory() && f.canRead() && f.canWrite();
  40. }
  41. }