* Save an array of short values from memory to file. * * Convert to the correct endianness first, if necessary. * @param buf Buffer containing the short values to save. * @param len Number of short values to save. * @param f File handle of the file to save to. * @return Save was succesfull. */
| 182 | * @return Save was succesfull. |
| 183 | */ |
| 184 | static bool save_short(short *buf, int len, FILE *f) |
| 185 | { |
| 186 | SWAP_SHORTS(buf, len); /* to MAC */ |
| 187 | |
| 188 | if ((int)fwrite(buf, sizeof(short), len, f) != len) { |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | SWAP_SHORTS(buf, len); /* back to intel */ |
| 193 | |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Load a city file from a given filename and (optionally) directory. |