Complete.Org: Mailing Lists: Archives: discussion: March 2006:
[aclug-L] Re: C questions
Home

[aclug-L] Re: C questions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: discussion@xxxxxxxxx
Subject: [aclug-L] Re: C questions
From: "Jonathan Hall" <flimzy@xxxxxxxxxx>
Date: Sun, 12 Mar 2006 19:47:57 -0600 (CST)
Reply-to: discussion@xxxxxxxxx

Octal is normally represented with a leading 0.  Thus 0755 is octal,
whereas 755 would be decimal.  0x755 would be hexidecimal... etc


> Yes, that's true and once you take 755 to decimal you
> can give it to a mode_t variable, then feed it to
> open, mkdir, etc. But I guess I'm still wondering how
>
> mkdir("dirname", 0755);
>
> gets converted.
>
> The issue is I'm writing my own tar utility. The mtime
> gets stored as an 11-digit char string that's supposed
> to be an octal number, so you have to turn it back
> into a decimal. I had to do an atoll() on the 11-digit
> char string, assigning to a long long variable, then
> convert that from octal to decimal to get the utime's
> time_t variable fed properly. That can't be the most
> elegant way to do this....
>
> LB
>
> --- Jonathan Hall <flimzy@xxxxxxxxxx> wrote:
>
>> Permissions are represented in octal.  0755 is octal
>> for 493.  Certianly
>> you can assign the value to a numeric variable, and
>> pass that to the
>> mkdir() function.
>>
>>
>>
>> > I'm trying to create a directory in C where I use
>> >
>> > mkdir(const char *pathname, mode_t mode);
>> >
>> > I'd like to take a simple string "0775" and
>> somehow
>> > use that for the mode argument. I'm getting the
>> > permissions as a char string from a file. Now, if
>> you
>> > do this:
>> >
>> > mkdir ("mydir", 0755); /* 0755 directly typed in
>> */
>> >
>> > It works fine. But I can't figure out how to get a
>> > variable (char or otherwise) with 0755 in it that
>> > mkdir will accept. Of course I could parse each
>> letter
>> > and build the variable, but that just isn't very
>> > elegant.
>> >
>> > I'm also trying this for utime(), i.e., trying to
>> feed
>> > the utimbuf argument to utime from a string I'm
>> > getting from a file.
>> >
>> >
>> > LB
>> >
>> > __________________________________________________
>> > Do You Yahoo!?
>> > Tired of spam?  Yahoo! Mail has the best spam
>> protection around
>> > http://mail.yahoo.com
>> >
>> > -- This is the discussion@xxxxxxxxx list.  To
>> unsubscribe,
>> > visit
>> http://www.complete.org/cgi-bin/listargate-aclug.cgi
>> >
>> >
>>
>>
>> -- This is the discussion@xxxxxxxxx list.  To
>> unsubscribe,
>> visit
>> http://www.complete.org/cgi-bin/listargate-aclug.cgi
>>
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> -- This is the discussion@xxxxxxxxx list.  To unsubscribe,
> visit http://www.complete.org/cgi-bin/listargate-aclug.cgi
>
>


-- This is the discussion@xxxxxxxxx list.  To unsubscribe,
visit http://www.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]