tool/CommandFoeWrite.cpp
changeset 1870 0cee1fb7f0fd
parent 1869 14f634f5b613
child 1968 4f682084c643
child 1991 15d656ef81af
equal deleted inserted replaced
1869:14f634f5b613 1870:0cee1fb7f0fd
    80 
    80 
    81 /****************************************************************************/
    81 /****************************************************************************/
    82 
    82 
    83 void CommandFoeWrite::execute(const StringVector &args)
    83 void CommandFoeWrite::execute(const StringVector &args)
    84 {
    84 {
    85 	MasterIndexList masterIndices;
       
    86     stringstream err;
    85     stringstream err;
    87     ec_ioctl_slave_foe_t data;
    86     ec_ioctl_slave_foe_t data;
    88     ifstream file;
    87     ifstream file;
    89     SlaveList slaves;
    88     SlaveList slaves;
    90     string storeFileName;
    89     string storeFileName;
    91 
    90 
    92     if (args.size() != 1) {
    91     if (args.size() != 1) {
    93         err << "'" << getName() << "' takes exactly one argument!";
    92         err << "'" << getName() << "' takes exactly one argument!";
    94         throwInvalidUsageException(err);
    93         throwInvalidUsageException(err);
    95     }
    94     }
    96 
       
    97 	masterIndices = getMasterIndices();
       
    98     if (masterIndices.size() != 1) {
       
    99         err << getName() << " requires to select a single master!";
       
   100         throwInvalidUsageException(err);
       
   101     }
       
   102     MasterDevice m(masterIndices.front());
       
   103 
    95 
   104     if (args[0] == "-") {
    96     if (args[0] == "-") {
   105         loadFoeData(&data, cin);
    97         loadFoeData(&data, cin);
   106         if (getOutputFile().empty()) {
    98         if (getOutputFile().empty()) {
   107             err << "Please specify a filename for the slave side"
    99             err << "Please specify a filename for the slave side"
   126         } else {
   118         } else {
   127             storeFileName = getOutputFile();
   119             storeFileName = getOutputFile();
   128         }
   120         }
   129     }
   121     }
   130 
   122 
       
   123     MasterDevice m(getSingleMasterIndex());
   131     try {
   124     try {
   132         m.open(MasterDevice::ReadWrite);
   125         m.open(MasterDevice::ReadWrite);
   133     } catch (MasterDeviceException &e) {
   126     } catch (MasterDeviceException &e) {
   134         if (data.buffer_size)
   127         if (data.buffer_size)
   135             delete [] data.buffer;
   128             delete [] data.buffer;