Eric Hodel
8/14/2007 6:34:00 PM
On Aug 14, 2007, at 05:59, unbewust wrote:
> On 14 août, 11:31, Eric Hodel <drbr...@segment7.net> wrote:
>> On Aug 14, 2007, at 01:49, unbewust wrote:
>>> i write a C extension to Ruby, some methods are dealing with octal
>>> number (bytes in english ?) for the file permission :
>>>
>>> ie something like that :
>>>
>>> 0777 or 0644 the first 0 (zero) meaning the following is a number
>>> coded in octal.
>>>
>>> that's OK for input of octal number if for example, from ruby the
>>> user
>>> write :
>>>
>>> this_file.perms = 0777 (then with the first 0)
>>>
>>> i get the right number
>>>
>>> however, for the time being, i'm returning, for the same value :
>>>
>>> 777 instead of 0777 when the user wants to read the perms,, then my
>>> question how to return within a C est to Ruby an integer coded in
>>> octal ???
>>>
>>> thought, at that time i'm usinbg INT2FIX ( )
>>
>> The easiest way will probably be to use sprintf. From C, use
>> rb_f_sprintf.
>
> OK, thanks, but i don't want to print it just have it as a return
> value then you mean i can use sprintf to print to stdout and the value
> will be cached by Ruby ?
sprintf returns a String. You can print it with puts if you want, or
use it later.
--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars