| 2412 | } |
| 2413 | |
| 2414 | static int preload_parse(FSDevice *fs, const char *fname, BOOL is_new) |
| 2415 | { |
| 2416 | FSINode *n; |
| 2417 | char *buf; |
| 2418 | size_t size; |
| 2419 | |
| 2420 | n = inode_search_path(fs, fname); |
| 2421 | if (!n || n->type != FT_REG || n->u.reg.state != REG_STATE_LOADED) |
| 2422 | return -1; |
| 2423 | /* transform to zero terminated string */ |
| 2424 | size = n->u.reg.size; |
| 2425 | buf = malloc(size + 1); |
| 2426 | file_buffer_read(&n->u.reg.fbuf, 0, (uint8_t *)buf, size); |
| 2427 | buf[size] = '\0'; |
| 2428 | if (is_new) |
| 2429 | preload_parse_str(fs, buf); |
| 2430 | else |
| 2431 | preload_parse_str_old(fs, buf); |
| 2432 | free(buf); |
| 2433 | return 0; |
| 2434 | } |
| 2435 | |
| 2436 | |
| 2437 |
no test coverage detected