steinbergmedia / vst3sdk

VST 3 Plug-In SDK
Other
1.59k stars 162 forks source link

FileStream class is broken by design #29

Closed nickallen74 closed 3 years ago

nickallen74 commented 5 years ago

The FileStream class in the SDK is a thin wrapper around the C FILE* type. Unfortunately when using this for writing the actual writing happens in the fclose method (as fwrite calls are likely just into a buffer in RAM). The fclose method is only called in the FileStream destructor and any error code from fclose is silently ignored.

Doing the actual writing to disk when the ref count goes to 0 is not a good idea and swallowing up the error code and not being able to report it to the user in a meaningful way (eg disk full, permission denied) is bad programming practice.

Suggestion would be to add an explicit close method to the FileStream class so that when writing something to the stream it is possible to know for sure whether the write succeeded .

Unfortunately, getting useful error messages would require a redesign of the entire stream API as all methods just return a tresult which never contains any useful error message.

Spacechild1 commented 5 years ago

Unfortunately, getting useful error messages would require a redesign of the entire stream API as all methods just return a tresult which never contains any useful error message.

They would just need to add some IO specific members to the tresult enum, e.g. kPermissionDenied

ygrabit commented 3 years ago

no plan for now to update this class