Inquiry Regarding std::ifstream Compatibility in Steinberg VST SDK

Hello VST Community,

I hope this message finds you well. I am currently working on a VST plugin using the Steinberg VST SDK, and I have encountered an issue with using std::ifstream to read binary files within the SDK environment.

Here’s a snippet of the code in question:

std::string get_file_contents(const char* filename)
{

	std::ifstream in(filename, std::ios::binary);

	if (in)
	{
		std::string contents;
		in.seekg(0, std::ios::end);
		contents.resize(in.tellg());
		in.seekg(0, std::ios::beg);
		in.read(&contents[0], contents.size());
		in.close();
		return(contents);
	}

	throw(errno);
}

It appears that std::ifstream might not be working as expected in the context of the VST SDK. I would appreciate any insights or recommendations from the community on alternative methods or best practices for loading and reading binary files in the Steinberg VST SDK environment.

Thank you in advance for your assistance!

Did you check the example implementation in the VST 3 SDK?
public.sdk/source/common/readfile.h

1 Like