tool/CommandFoeWrite.cpp
changeset 1826 ec6223c3b7ec
parent 1804 742607c464c4
child 1869 14f634f5b613
equal deleted inserted replaced
1825:65781b048a47 1826:ec6223c3b7ec
    35 #include <fstream>
    35 #include <fstream>
    36 using namespace std;
    36 using namespace std;
    37 
    37 
    38 #include "CommandFoeWrite.h"
    38 #include "CommandFoeWrite.h"
    39 #include "foe.h"
    39 #include "foe.h"
       
    40 #include "MasterDevice.h"
    40 
    41 
    41 /*****************************************************************************/
    42 /*****************************************************************************/
    42 
    43 
    43 CommandFoeWrite::CommandFoeWrite():
    44 CommandFoeWrite::CommandFoeWrite():
    44     FoeCommand("foe_write", "Store a file on a slave via FoE.")
    45     FoeCommand("foe_write", "Store a file on a slave via FoE.")
    77     return str.str();
    78     return str.str();
    78 }
    79 }
    79 
    80 
    80 /****************************************************************************/
    81 /****************************************************************************/
    81 
    82 
    82 void CommandFoeWrite::execute(MasterDevice &m, const StringVector &args)
    83 void CommandFoeWrite::execute(const StringVector &args)
    83 {
    84 {
    84     stringstream err;
    85     stringstream err;
    85     ec_ioctl_slave_foe_t data;
    86     ec_ioctl_slave_foe_t data;
    86     ifstream file;
    87     ifstream file;
    87     SlaveList slaves;
    88     SlaveList slaves;
    89 
    90 
    90     if (args.size() != 1) {
    91     if (args.size() != 1) {
    91         err << "'" << getName() << "' takes exactly one argument!";
    92         err << "'" << getName() << "' takes exactly one argument!";
    92         throwInvalidUsageException(err);
    93         throwInvalidUsageException(err);
    93     }
    94     }
       
    95 
       
    96     if (getMasterIndices().size() != 1) {
       
    97         err << getName() << " requires to select a single master!";
       
    98         throwInvalidUsageException(err);
       
    99     }
       
   100     MasterDevice m(getMasterIndices().front());
    94 
   101 
    95     if (args[0] == "-") {
   102     if (args[0] == "-") {
    96         loadFoeData(&data, cin);
   103         loadFoeData(&data, cin);
    97         if (getOutputFile().empty()) {
   104         if (getOutputFile().empty()) {
    98             err << "Please specify a filename for the slave side"
   105             err << "Please specify a filename for the slave side"