Changeset 548 for abuse/trunk
- Timestamp:
- Apr 29, 2011, 12:24:38 AM (12 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/specs.cpp
r546 r548 568 568 { 569 569 spec_entry *se = entries[i]; 570 if (se->data) 571 free(data); 572 570 free(se->data); 573 571 se->data = malloc(se->size); 574 572 fp->seek(se->offset, SEEK_SET); … … 720 718 fp->read(&len,1); 721 719 se->type=type; 720 se->data = NULL; 722 721 se->name=dp+sizeof(spec_entry); 723 722 fp->read(se->name,len); -
abuse/trunk/src/tool/abuse-tool.cpp
r547 r548 156 156 return EXIT_SUCCESS; 157 157 } 158 159 if (cmd == CMD_GET) 158 else if (cmd == CMD_GET) 160 159 { 161 160 int id = atoi(argv[3]); … … 180 179 return EXIT_SUCCESS; 181 180 } 182 183 if (cmd == CMD_GETPCX) 181 else if (cmd == CMD_GETPCX) 184 182 { 185 183 palette *pal; … … 202 200 return EXIT_SUCCESS; 203 201 } 204 205 if (cmd == CMD_MOVE) 202 else if (cmd == CMD_MOVE) 206 203 { 207 204 int src = atoi(argv[3]); … … 220 217 dir.entries[src] = dir.entries[src + d]; 221 218 dir.entries[dst] = tmp; 222 223 dir.calc_offsets(); 224 fp.seek(0, SEEK_SET); // FIXME: create a new file 225 dir.write(&fp); 226 for (int i = 0; i < dir.total; i++) 227 fp.write(dir.entries[i]->data, dir.entries[i]->size); 228 } 219 } 220 else if (cmd == CMD_RENAME) 221 { 222 int id = atoi(argv[3]); 223 224 if (id < 0 || id >= dir.total) 225 { 226 fprintf(stderr, "abuse-tool: id %i out of range\n", id); 227 return EXIT_FAILURE; 228 } 229 230 dir.FullyLoad(&fp); 231 dir.entries[id]->name = argv[4]; 232 } 233 else if (cmd == CMD_DEL) 234 { 235 int id = atoi(argv[3]); 236 237 if (id < 0 || id >= dir.total) 238 { 239 fprintf(stderr, "abuse-tool: id %i out of range\n", id); 240 return EXIT_FAILURE; 241 } 242 243 dir.total--; 244 for (int i = id; i < dir.total; i++) 245 dir.entries[i] = dir.entries[i + 1]; 246 247 dir.FullyLoad(&fp); 248 } 249 else 250 { 251 /* Not implemented yet */ 252 return EXIT_FAILURE; 253 } 254 255 /* If we get here, we need to write the directory back */ 256 dir.calc_offsets(); 257 fp.seek(0, SEEK_SET); // FIXME: create a new file 258 dir.write(&fp); 259 for (int i = 0; i < dir.total; i++) 260 fp.write(dir.entries[i]->data, dir.entries[i]->size); 229 261 230 262 return EXIT_SUCCESS; … … 239 271 " get <id> dump entry <id> to stdout\n" 240 272 " getpcx <id> dump PCX image <id> to stdout\n" 241 " move <i1> <i2> move entry <i1> to <i2>\n"); 273 " del <id> delete entry <id>\n" 274 " rename <id> <name> rename entry <id> to <name>\n" 275 " move <id1> <id2> move entry <id1> to <id2>\n"); 242 276 } 243 277
Note: See TracChangeset
for help on using the changeset viewer.