Unix Programming - getting file attributes

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2004 > getting file attributes





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author getting file attributes
satish challa

2004-08-29, 2:49 am

Hi,
i want to the know the following,could any of u tell me.
How to get the attributes of a file(Linux) through a C program
like the time,the file last modified,last accessed etc.
How to check the System time in C,are there any functions defined
in time.h or any system calls.
How to access a remote file through a C program.
Thank you
SM Ryan

2004-08-29, 2:49 am

satish_challa@sify.com (satish challa) wrote:
# Hi,
# i want to the know the following,could any of u tell me.
# How to get the attributes of a file(Linux) through a C program
# like the time,the file last modified,last accessed etc.

Check the stat man page
man 2 stat

That will get modified and access times, mode, size, etc,

# How to check the System time in C,are there any functions defined
# in time.h or any system calls.

You can get the time in seconds with time(0)

# How to access a remote file through a C program.

Unless you're thinking of something like a locally mounted NFS volume,
this can be very complicated. You can check up on various URL libraries.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Where do you get those wonderful toys?
Ganesh

2004-08-29, 7:48 am

satish_challa@sify.com (satish challa) wrote in message news:<ef44bd70.0408282159.34984c35@posting.google.com>...
> Hi,
> i want to the know the following,could any of u tell me.
> How to get the attributes of a file(Linux) through a C program
> like the time,the file last modified,last accessed etc.


man 2 stat

> How to check the System time in C,are there any functions defined
> in time.h or any system calls.


man 2 time
man 3 ctime

> How to access a remote file through a C program.
> Thank you

Pascal Bourguignon

2004-08-29, 5:52 pm

satish_challa@sify.com (satish challa) writes:
> How to access a remote file through a C program.


You should read various RFC (http://www.rfc-editor.org/)

Search for NFS, FTP, HTTP, WebDAV, and perhaps others that I don't
remember right now. There, you'll have all the specifications needed
to implement the protocols needed to access a remote file through a C
program.


--
__Pascal Bourguignon__ http://www.informatimago.com/

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.
Barry Kimelman

2004-09-02, 6:50 pm

[This followup was posted to comp.unix.programmer]

While wandering through cyberspace on 28 Aug 2004 22:59:45 -0700 satish
challa said :
> Hi,
> i want to the know the following,could any of u tell me.
> How to get the attributes of a file(Linux) through a C program
> like the time,the file last modified,last accessed etc.


the "stat" or "lstat" system calls can get you the informatiion you need



> How to check the System time in C,are there any functions defined
> in time.h or any system calls.


the "time" function can give you the system time (in seconds elapsed
since the great beginning)


> How to access a remote file through a C program.
> Thank you
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com