/** * Nextcloud Android client application * * @author Bartosz Przybylski * Copyright (C) 2016 Nextcloud * Copyright (C) 2016 Bartosz Przybylski * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this program. If not, see . */ package com.owncloud.android.datastorage.providers; import com.owncloud.android.datastorage.StoragePoint; import java.util.Locale; import java.util.Vector; /** * @author Bartosz Przybylski */ public class MountCommandStoragePointProvider extends AbstractCommandLineStoragePoint { static private final String[] sCommand = new String[] { "mount" }; @Override protected String[] getCommand() { return sCommand; } @Override public Vector getAvailableStoragePoint() { Vector result = new Vector<>(); for (String p : getPotentialPaths(getCommandLineResult())) if (canBeAddedToAvailableList(result, p)) result.add(new StoragePoint(p, p)); return result; } private Vector getPotentialPaths(String mounted) { final Vector result = new Vector<>(); final String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*"; for (String line : mounted.split("\n")) if (!line.toLowerCase(Locale.US).contains("asec") && line.matches(reg)) { String parts[] = line.split(" "); for (String path : parts) { if (path.startsWith("/") && !path.toLowerCase(Locale.US).contains("vold")) result.add(path); } } return result; } }