Code: Select all
createpack()
addpackfile() / addpackmemory()
closepack()
My problem was, that if you want to reliably make sure an archive is physically written to the media, how do i achieve that? I wouldnt want to tell the user "Ok everything is fine" and instantly allow them to remove the media while actually the windows OS has the most recent change not written to the physical media, but just in a buffer/cache marked as "dirty" so at a later shutdown, it would be written to the media.
Imagine a user does a backup on a removeable media. The media could be removed before the changed cache is physically written to the media, therefore the media and archive would be in a corrupt state.
That is an old basic problem of all operating systems with removeable media. Unixes therefore "lock" the media and whoever removes the media without unlocking it first (aka ejecting it which writes all dirty cache pages physically to a media) ends up with an inconsistent logical media. PureBasic offers the flushfilebuffers command to avoid that. The problem is - the command requires a "fileid" but the packer library uses a packer library id.
So how to solve this problem officially to make the packer library reliably useable on removable media?
An official command like flushfilebuffers which works with a pack ID maybe? Alternatively an official way to get a file ID from an open packer library archive which can be used after closepack() - but that would seem a bit dirty for this usecase.