Object-oriented file API with safety improvements