Solved

File Details.

Posted on 2000-02-28
7
227 Views
Last Modified: 2010-04-02
Hi,

I am running gcc under solaris, i need to know the details of a given file such as its size,  date on which the file was last updated/edited etc. Is there any inbuilt function or other.  responses very much appreciated.

-gsbabu
0
Comment
Question by:gsbabu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2566333
Unix has a file called fstat() or stat() or something like that.  If linux has it it should provide the info you want.
0
 

Accepted Solution

by:
Marthi earned 35 total points
ID: 2566336
Yes. The function is fstat() or stat().
Here's a man page snippet

NAME
       stat, fstat, lstat - get file status

SYNOPSIS
       #include <sys/stat.h>
       #include <unistd.h>

       int stat(const char *file_name, struct stat *buf);
       int fstat(int filedes, struct stat *buf);
       int lstat(const char *file_name, struct stat *buf);

DESCRIPTION
       These  functions  return  information  about the specified
       file.  You do not need any access rights to  the  file  to
       get  this  information  but  you need search rights to all
       directories named in the path leading to the file.


0
 

Author Comment

by:gsbabu
ID: 2566492
i have used stat(), but i don't know the exact syntax of the second parameter, i get error for

stat("/home/cachet/longfilename",time_t->st_ctime)

please guide me where i am wrong.

-gsbabu
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:nietod
ID: 2566712
Its a pointer to a structure of type stat.  The function will fill in this structure with the information about the file.
0
 

Author Comment

by:gsbabu
ID: 2566758
Could you correct the second parameter as to how pass a pointer.

-gsbabu
0
 
LVL 22

Expert Comment

by:nietod
ID: 2566765
struct stat Stat;

stat("/home/cachet/longfilename",&Stat)

then use Stat.????
0
 

Author Comment

by:gsbabu
ID: 2566810
Thanks for your suggestions/comments.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question