/** * Test device accessibility. * * @return true if the device is available */ public boolean test() { UtilGUI.waiting(); // waiting cursor boolean bOK = false; boolean bWasMounted = bMounted; // store mounted state of device before // mount test try { if (!bMounted) { mount(true); } } catch (final Exception e) { UtilGUI.stopWaiting(); return false; } if (getLongValue(Const.XML_TYPE) != 5) { // not a remote device final File file = new File(sUrl); if (file.exists() && file.canRead()) { // see if the url exists // and is readable // check if this device was void boolean bVoid = true; for (org.jajuk.base.File f : FileManager.getInstance().getFiles()) { if (f.getDirectory().getDevice().equals(this)) { // at least one field in this device bVoid = false; break; } } if (!bVoid) { // if the device is not supposed to be void, // check if it is the case, if no, the device // must not be unix-mounted if (file.list().length > 0) { bOK = true; } } else { // device is void, OK we assume it is accessible bOK = true; } } } else { bOK = false; // TBI } // unmount the device if it was mounted only for the test if (!bWasMounted) { try { unmount(false, false); } catch (final Exception e1) { Log.error(e1); } } UtilGUI.stopWaiting(); return bOK; }