added method for more easily accessing the coffee filesystem interface

This commit is contained in:
fros4943 2009-10-08 14:41:20 +00:00
parent b0291ca5a8
commit 92eecd3e38
2 changed files with 33 additions and 3 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: SkyMote.java,v 1.16 2009/09/17 13:19:08 fros4943 Exp $
* $Id: SkyMote.java,v 1.17 2009/10/08 14:41:20 fros4943 Exp $
*/
package se.sics.cooja.mspmote;
@ -36,6 +36,7 @@ import java.io.File;
import org.apache.log4j.Logger;
import se.sics.cooja.Simulation;
import se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem;
import se.sics.mspsim.platform.sky.SkyNode;
/**
@ -69,6 +70,10 @@ public class SkyMote extends MspMote {
skyNode.setNodeID(newID);
}
public SkyCoffeeFilesystem getFilesystem() {
return getInterfaces().getInterfaceOfType(SkyCoffeeFilesystem.class);
}
public String toString() {
return "Sky " + getID();
}

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: SkyCoffeeFilesystem.java,v 1.1 2009/08/11 17:09:16 fros4943 Exp $
* $Id: SkyCoffeeFilesystem.java,v 1.2 2009/10/08 14:41:20 fros4943 Exp $
*/
package se.sics.cooja.mspmote.interfaces;
@ -36,7 +36,6 @@ import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@ -312,4 +311,30 @@ public class SkyCoffeeFilesystem extends MoteInterface {
return getValueAt(0, c).getClass();
}
};
public boolean extractFile(String coffeeFile, String diskFilename) {
try {
updateFS();
return coffeeFS.extractFile(coffeeFile, new File(diskFilename));
} catch (RuntimeException e) {
logger.fatal("Error: " + e.getMessage(), e);
return false;
} catch (IOException e) {
logger.fatal("Error: " + e.getMessage(), e);
return false;
}
}
public boolean insertFile(String diskFilename) {
try {
return coffeeFS.insertFile(diskFilename) != null;
} catch (RuntimeException e) {
logger.fatal("Error: " + e.getMessage(), e);
return false;
} catch (IOException e) {
logger.fatal("Error: " + e.getMessage(), e);
return false;
}
}
}