def _get_file_stash(self, path):
path = os.path.normcase(path)<EOL>head, old_head = os.path.dirname(path), None<EOL>save_dir = None<EOL>while head != old_head:<EOL><INDENT>try:<EOL><INDENT>save_dir = self._save_dirs[head]<EOL>break<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>head, old_head = os.path.dirname(head), head<EOL><DEDENT>else:<EOL><INDENT>head = os.path.dirname(path)<EOL>save_dir = TempDirectory(kind='<STR_LIT>')<EOL>save_dir.create()<EOL>self._save_dirs[head] = save_dir<EOL><DEDENT>relpath = os.path.relpath(path, head)<EOL>if relpath and relpath != os.path.curdir:<EOL><INDENT>return os.path.join(save_dir.path, relpath)<EOL><DEDENT>return save_dir.path<EOL>
Stashes a file.

        If no root has been provided, one will be created for the directory
        in the user's temp directory.