It’s a question I had to ask myself multiple times over the last few months. Depending on the context the answer can be:
very simple, just call the standard library function extremely hard, don’t trust anything If you are an app developer, you’re lucky and it’s almost always the first answer. If you develop something with a security boundary which involves files in any way, the correct answer is very likely the second one.