I'm writing a program that downloads several files at once from several different servers (one download thread per server, of course!). I'm worried about having multiple files growing on disk simultaneously causing disk fragmentation and I'd like to mitigate that by preallocating space on disk for the full file's length (as reported by the Content-Length header) before starting the download, ideally without increasing the file's apparent length (so I can resume failed downloads just by opening the partially downloaded file in append mode).
Is that possible in a platform-independent manner?