In the persist() implementation for Windows, I noticed a comment:
// TODO: We should probably do this in one-shot using SetFileInformationByHandle but the API is
// really painful.
I was interested in seeing if I could work through the painful API and file a PR to implement this. However, SetFileInformationByHandle does not appear to allow moving a file and modifying its attributes at the same time. The FileAttributes are only contained in FILE_BASIC_INFO, the destination path is only contained in FILE_RENAME_INFO, and SetFileInformationByHandle only allows one of these to be passed at a time. So it would still end up taking 3 calls to SetFileInformationByHandle; the only benefit is that we could use the handle directly instead of going through the path. (NtSetInformationFile is more powerful, but it can still only change one of the FILE_BASIC_INFORMATION or FILE_RENAME_INFORMATION at a time.)
As far as I can tell, the closest thing to being able to perform both operations "in one-shot" would be to use the Transactional NTFS functions, which, as the name suggests, only work with NTFS.
In the
persist()
implementation for Windows, I noticed a comment:I was interested in seeing if I could work through the painful API and file a PR to implement this. However,
SetFileInformationByHandle
does not appear to allow moving a file and modifying its attributes at the same time. TheFileAttributes
are only contained inFILE_BASIC_INFO
, the destination path is only contained inFILE_RENAME_INFO
, andSetFileInformationByHandle
only allows one of these to be passed at a time. So it would still end up taking 3 calls toSetFileInformationByHandle
; the only benefit is that we could use the handle directly instead of going through the path. (NtSetInformationFile
is more powerful, but it can still only change one of theFILE_BASIC_INFORMATION
orFILE_RENAME_INFORMATION
at a time.)As far as I can tell, the closest thing to being able to perform both operations "in one-shot" would be to use the Transactional NTFS functions, which, as the name suggests, only work with NTFS.