Subject: bug#10733: 24.0.93; w32 file truncation

From: Eli Zaretskii <[email-masked]>
Date: Tue, 07 Feb 2012 06:02:49 +0200

> From: Óscar Fuentes <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Tue, 07 Feb 2012 00:27:07 +0100
> 
> >> Symlinks are detected and handled specially on MSVCRT's stat. In
> >> aessence, for symlinks it uses fstat.
> >
> > But fstat probably calls GetFileInformationByHandle under the hood,
> > and we already call that function in w32.c:stat.  So maybe the fix is
> > not as ugly and inelegant as you thought.
> 
> Yup. This patch fixes the problem:

Thanks.

> Maybe it can be integrated in the
> 
> if (!(NILP(Vw32_get_true_file_attributes) ...
> 
> hence reusing the calls to CreateFile and GetFileInformationByHandle and
> shortening the patch, but as I don't know what
> Vw32_get_true_file_attributes does, preferread to follow the safe way.

You did right: w32-get-true-file-attributes can be set by the user to
nil, if she wants her file ops faster.

> And the fix is just for the size. Don't know if there are other
> attributes suffer from the same problem. Possibly the right thing is to
> do what MSVCRT does:
> 
> if is-symlink?
>   use fstat
> fi

Since fstat is also reimplemented, I'd rather do what it does inline.

For that, we need to know which other attributes are reported
different.  Or maybe just test for the reparse point up front and do
all the work for the target instead.