Report what is in an archive's root, so the user can tell one that holds a * save from one that is not there at all. Returns the number of root entries, * -1 if there is no archive under that id. */
| 85 | * save from one that is not there at all. Returns the number of root entries, |
| 86 | * -1 if there is no archive under that id. */ |
| 87 | int describeExtdata(int extdataId) |
| 88 | { |
| 89 | char line[128]; |
| 90 | int h; |
| 91 | int count; |
| 92 | struct directory* dir; |
| 93 | int i; |
| 94 | |
| 95 | h = sav_open_extdata(extdataId); |
| 96 | if (h < 0) { |
| 97 | return -1; |
| 98 | } |
| 99 | |
| 100 | dir = sav_list(h, "/"); |
| 101 | if (dir == NULL) { |
| 102 | sav_close(h); |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | count = dir->count; |
| 107 | sprintf(line, "extdata 0x%08X: %d entr(y/ies) in the root", extdataId, count); |
| 108 | script_log(line); |
| 109 | for (i = 0; i < count && i < LIST_MAX; i++) { |
| 110 | printf(" %s\n", dir->files[i]); |
| 111 | } |
| 112 | if (count > LIST_MAX) { |
| 113 | printf(" ... and %d more\n", count - LIST_MAX); |
| 114 | } |
| 115 | |
| 116 | delete_directory(dir); |
| 117 | sav_close(h); |
| 118 | return count; |
| 119 | } |
| 120 | |
| 121 | /* Turn extdata_create's return value into something the user can act on. */ |
| 122 | void reportCreateResult(int res, char* name, int extdataId, int defaultId) |
no outgoing calls
no test coverage detected