| 173 | } |
| 174 | |
| 175 | bool file_tmpl::file_copy(const char* from, const char* to_in) |
| 176 | { |
| 177 | string to_buf; |
| 178 | to_buf.format("%s/%s", path_to_.c_str(), to_in); |
| 179 | |
| 180 | const char* to = to_buf.c_str(); |
| 181 | |
| 182 | if (strcasecmp(from, to) == 0) { |
| 183 | printf("from(%s) == to(%s)\r\n", from, to); |
| 184 | return false; |
| 185 | } |
| 186 | |
| 187 | ifstream in; |
| 188 | if (!in.open_read(from)) { |
| 189 | printf("open %s error: %s\r\n", from, last_serror()); |
| 190 | return false; |
| 191 | } |
| 192 | |
| 193 | ofstream out; |
| 194 | if (!out.open_write(to)) { |
| 195 | printf("open %s error: %s\r\n", from, last_serror()); |
| 196 | return false; |
| 197 | } |
| 198 | |
| 199 | string buf; |
| 200 | |
| 201 | while (!in.eof()) { |
| 202 | if (!in.gets(buf, false)) { |
| 203 | break; |
| 204 | } |
| 205 | if (out.write(buf) < 0) { |
| 206 | printf("write to %s error: %s\r\n", to, last_serror()); |
| 207 | return false; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | printf("create %s ok\r\n", to); |
| 212 | return true; |
| 213 | } |
| 214 | |
| 215 | bool file_tmpl::files_copy(const char* name, const FILE_FROM_TO* tab) |
| 216 | { |
no test coverage detected