GetFinalPathNameByHandleW(,,N,) returns:
- < N on success (this value does not include the size of the terminating null character)
- >= N if buffer is too small (this value includes the size of the terminating null character)
So, when N == Buffer.capacity() - 1, we need to resize buffer if return value is > Buffer.capacity() - 2.
Also, we can set N to Buffer.capacity().
Thus, without this patch realPathFromHandle() returns unfilled buffer when length of the final path of the file is equal to Buffer.capacity() or Buffer.capacity() - 1.
If Buffer.capacity() == 0 this check will fail. This case would have also caused issues with the previous code.