<br><br><div class="gmail_quote">2011/9/20 Lionel Elie Mamane <span dir="ltr"><<a href="mailto:lionel@mamane.lu">lionel@mamane.lu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, Sep 12, 2011 at 10:45:31PM +0200, CaStarCo wrote:<br>
<br>
> @Lionel , What is the QuadPart member of the structure? The high<br>
> part? the low part? or another thing?<br>
<br>
</div>The union is fully described at<br>
<a href="http://msdn.microsoft.com/en-us/library/aa383713%28v=vs.85%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/aa383713(v=vs.85).aspx</a><br>
<br>
Are you familiar with the concept of C/C++ union? If not, Google gives<br>
a few hits that don't seem too bad at first sight:<br>
<br></blockquote><div><br>Ok, thanks! :) I know the concept of union, my problem was the definition of "QuadPart".<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<a href="http://www.cplusplus.com/doc/tutorial/other_data_types/#union" target="_blank">http://www.cplusplus.com/doc/tutorial/other_data_types/#union</a><br>
<a href="http://www.go4expert.com/forums/showthread.php?t=15" target="_blank">http://www.go4expert.com/forums/showthread.php?t=15</a><br>
<a href="http://en.wikipedia.org/wiki/Union_%28computer_science%29" target="_blank">http://en.wikipedia.org/wiki/Union_(computer_science)</a><br>
<a href="http://msdn.microsoft.com/en-us/library/y9zewe0d%28v=vs.80%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/y9zewe0d(v=vs.80).aspx</a><br>
<br>
To get to your question, the QuadPart is the whole 64 bits, that is<br>
the combination of the high part *and* the low part.<br>
<br>
Essentially, the paragraph I quoted says that to treat the FILETIME<br>
value as a 64bit integer, one should proceed as such:<br>
<br>
__int64 Value;<br>
FILETIME *ft = // some value<br>
ULARGE_INTEGER t;<br>
t.LowPart = ft->dwLowDateTime;<br>
t.HighPart = ft->dwHighDateTime;<br>
// Now, t.QuadPart contains the right 64 bits integer<br>
Value = t.QuadPart; // or use t.QuadPart directly instead of Value<br>
<br>
instead of:<br>
<br>
Value = *(__int64*)ft;<br>
<br>
<br></blockquote><div><br>It's true, using unions is clearer and cleaner than using forced type castings.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Do not hesitate to CC to me any additional question you have on this<br>
matter.<br>
<div><div></div><div class="h5"><br>
<br>
> 2011/9/12 Lionel Elie Mamane <<a href="mailto:lionel@mamane.lu">lionel@mamane.lu</a>><br>
<br>
>> On Sun, Sep 11, 2011 at 10:04:52PM +0200, CaStarCo wrote:<br>
>>> I've created a second (very little too) patch to reduce the scope of a<br>
>>> variable.<br>
<br>
>>> --- a/sal/osl/w32/file_dirvol.cxx<br>
>>> +++ b/sal/osl/w32/file_dirvol.cxx<br>
>>> @@ -60,7 +60,6 @@ extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime<br>
<br>
>> Thank you for your contribution to LibreOffice, it is most<br>
>> welcome. Looking at that function in that file, it needs a more<br>
>> thorough cleanup, and maybe other functions in that file and/or in<br>
>> other files in the same directory; see<br>
>> <a href="http://msdn.microsoft.com/en-us/library/ms724284%28v=VS.85%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms724284%28v=VS.85%29.aspx</a>, in<br>
>> particular:<br>
<br>
>> It is not recommended that you add and subtract values from the<br>
>> FILETIME structure to obtain relative times. Instead, you should copy<br>
>> the low- and high-order parts of the file time to a ULARGE_INTEGER<br>
>> structure, perform 64-bit arithmetic on the QuadPart member, and copy<br>
>> the LowPart and HighPart members into the FILETIME structure.<br>
<br>
>> Do not cast a pointer to a FILETIME structure to either a<br>
>> ULARGE_INTEGER* or __int64* value because it can cause alignment<br>
>> faults on 64-bit Windows.<br>
<br>
>> It would be best to look at every place that FILETIME is used in that<br>
>> directory.<br>
<br>
>> Just in case you want to volunteer for that cleanup :)<br>
<br>
>> When you send a patch, could you please confirm the patch is licensed<br>
>> under MPL1.1/LGPLv3+? To make things easier, you can do a one-time<br>
>> blanket "all my patches" thing if you wish, sort of common to do that.<br>
<br>
</div></div><font color="#888888">--<br>
Lionel<br>
</font></blockquote></div><br>