-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Labels
Description
The problem is that 'rw' files can be two quite different things: either existing files or new files.
If it's a new file, some arguments are required (like channels, subtype etc.), if it's an already existing file, those arguments are forbidden (except for 'RAW' files).
As far as I know, there is no function in libsndfile that allows to check before opening which of the two cases we're dealing with.
I see three options which could theoretically work:
- Use a function from the Python standard library to check if the file already exists
- Try to open the file with libsndfile. If there is an error, check if the reason are the required arguments. If there is no error, check if any of the forbidden arguments were given and raise an error.
- Split
'rw'mode into two distinct modes, one that only works for existing files and another one that only works for new files (or alternatively, it can also delete the existing file content first, like 'w+' mode does in Python'sopen()function)
Are there more options?
I'm currently leaning towards option 3, see also #60.
Reactions are currently unavailable