Patrick Philipot wrote:

>RPT> st: make struct! [
>RPT>   VolumeNameBuffer [string!]
>RPT>   FileSystemNameBuffer [string!]
>RPT> ] reduce [VNB: make string! 100 FSNB: make string! 100]
>RPT> GetVolumeInfo "C:\" VNB 20 0 0 0 FSNB 20
>
>Thanks Romano
>
>Very strange indeed. And I don't get why it's working. It seems that
>Rebol is doing a lot of things behind my back.
>
>  
>
The fact is that a string! in a struct! is used by rebol like a C string 
(0 terminated).
So st/FileSystemNameBuffer return a rebol string which ends at the first 0.

But the problem is that you cannot pass st/FileSystemNameBuffer to 
GetVolumeInfo because st/FileSystemNameBuffer is indeed a Rebol string! 
copy of the C string in the struct. So I use this workaround:

        reduce [VNB: make string! 100 FSNB: make string! 100]

where I get in FNSB a pointer to the C string and then pass that pointer to 
GetVolumeInfo:

        GetVolumeInfo "C:\" VNB 20 0 0 0 FSNB 20

You must think that st/FileSystemNameBuffer is a pointer to the same memory 
area pointed by FNSB, the difference is that when Rebol uses the first, it 
makes a copy of that memory only until the first 0; when Rebol uses the second, 
it reads it until the string! length (which is 0 until you insert something in 
it, so it is always "" in our example). So:

        probe st/FileSystemNameBuffer ; "NTFS"
        probe FSNB ; ""

also if they share the same memory storage area.

-- 
Ciao
Romano Paolo Tenca

-- 
To unsubscribe from the list, just send an email to rebol-request
at rebol.com with unsubscribe as the subject.

Reply via email to