Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: re-encoding flac files with a new encoder (Read 2939 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: re-encoding flac files with a new encoder

Reply #25
Still it is interesting to know whether codecs originally developed for the Windows platform does any more sanity-checking of the written file on (an NTFS) drive. @bryant, what about WavPack? And @TBeck , even if Tak/Takc cannot (AFAIK) re-compress .tak files in-place?
For WavPack’s verify mode, the output file (which has a temporary name if the original is being overwritten) is closed, reopened, and reread in its entirety. Only if that passes the md5sum check (for lossless) is it renamed to the correct name (which deletes the original).

I think this is about as safe as you can easily get in a portable way. Yes, in some cases the entire file would be in cache (either in the OS or the drive), but there’s little chance that the file might not actually be being written at all (or be truncated).

On Linux this uses rename() which is reasonably safe (it does the rename and remove atomically and guarantees that if the operation fails, the old version will still be there). I wasn’t able to find anything equivalent on Windows that I could use, so it’s a separate remove and rename, which in theory leaves open the possibility of the original being deleted and the temp file not renamed (although it would still be there, and the name is obvious rather than gobbledygook).

As was mentioned, FLAC simply decodes the stream on its way out without even pretending to reread the file. This has the advantage that it works even when writing to pipes, and I seem to remember documentation somewhere stating that the purpose of this mode was intended more to verify the integrity of the algorithm on the given processor than the file integrity itself.