files permissions controll

A

and

How can I controll the permissions on a file in a c program.Are there
any macros or I have to use bitwise operators on the st_mode member of
the stat structure?For example I want to know if a owner have read
permission on a file.How can I do it?Thank you.
 
J

joychenqi

and said:
How can I controll the permissions on a file in a c program.Are there
any macros or I have to use bitwise operators on the st_mode member of
the stat structure?For example I want to know if a owner have read
permission on a file.How can I do it?Thank you.
 
J

James Kuyper

and said:
How can I controll the permissions on a file in a c program.Are there
any macros or I have to use bitwise operators on the st_mode member of
the stat structure?For example I want to know if a owner have read
permission on a file.How can I do it?Thank you.


The answer depends upon your operating system; the C standard doesn't
provide any generic mechanism for doing this; in particular, it doesn't
define a stat structure or an st_mode member thereof. You'll get the
best answers to a question about your particular operating system by
asking in a forum specific to that operating system, such as
comp.unix.programmer.

Do you want to "control the permissions" or "know if an owner ha read
permission"? If you are in fact using a unix or unix-like system (such
as linux), then the function you want for learning about permissions is
stat(), and yes, you do have to extract the appropriate bit from st_mode
for which the bitwise operators are the most appropriate tool. If you
actually want to control the permissions, then the appropriate function
is chmod() - type "man 2 chmod" for more details.

Followups redirected to comp.unix.programmer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top