This is a function extracted from django/core/files/move.py

I tracked the various changesets in which the code I extracted got written:
https://github.com/django/django/commit/58cd4902
https://github.com/django/django/commit/a9f0ae70

The discussion on https://code.djangoproject.com/ticket/8203 is relevant for the second commit linked above.

All the details of the current implementation are buried in the conversation above. Although I understand how the function works, I don't consider myself knowledgeable enough on how  behavior varies across multiple platforms as to write accurate comments.