equal
deleted
inserted
replaced
76 |
76 |
77 /****************************************************************************/ |
77 /****************************************************************************/ |
78 |
78 |
79 void CommandSiiWrite::execute(const StringVector &args) |
79 void CommandSiiWrite::execute(const StringVector &args) |
80 { |
80 { |
81 MasterIndexList masterIndices; |
|
82 stringstream err; |
81 stringstream err; |
83 ec_ioctl_slave_sii_t data; |
82 ec_ioctl_slave_sii_t data; |
84 ifstream file; |
83 ifstream file; |
85 SlaveList slaves; |
84 SlaveList slaves; |
86 |
85 |
87 if (args.size() != 1) { |
86 if (args.size() != 1) { |
88 err << "'" << getName() << "' takes exactly one argument!"; |
87 err << "'" << getName() << "' takes exactly one argument!"; |
89 throwInvalidUsageException(err); |
88 throwInvalidUsageException(err); |
90 } |
89 } |
91 |
|
92 masterIndices = getMasterIndices(); |
|
93 if (masterIndices.size() != 1) { |
|
94 err << getName() << " requires to select a single master!"; |
|
95 throwInvalidUsageException(err); |
|
96 } |
|
97 MasterDevice m(masterIndices.front()); |
|
98 |
90 |
99 if (args[0] == "-") { |
91 if (args[0] == "-") { |
100 loadSiiData(&data, cin); |
92 loadSiiData(&data, cin); |
101 } else { |
93 } else { |
102 file.open(args[0].c_str(), ifstream::in | ifstream::binary); |
94 file.open(args[0].c_str(), ifstream::in | ifstream::binary); |
115 delete [] data.words; |
107 delete [] data.words; |
116 throw e; |
108 throw e; |
117 } |
109 } |
118 } |
110 } |
119 |
111 |
|
112 MasterDevice m(getSingleMasterIndex()); |
120 try { |
113 try { |
121 m.open(MasterDevice::ReadWrite); |
114 m.open(MasterDevice::ReadWrite); |
122 } catch (MasterDeviceException &e) { |
115 } catch (MasterDeviceException &e) { |
123 delete [] data.words; |
116 delete [] data.words; |
124 throw e; |
117 throw e; |