File Details.

Posted on 2000-02-28
Last Modified: 2010-04-02

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.

Question by:gsbabu
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
LVL 22

Expert Comment

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.

Accepted Solution

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

       stat, fstat, lstat - get file status

       #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);

       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.


Author Comment

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


please guide me where i am wrong.

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

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

Author Comment

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

LVL 22

Expert Comment

ID: 2566765
struct stat Stat;


then use Stat.????

Author Comment

ID: 2566810
Thanks for your suggestions/comments.

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the real difference between C++ and Visual C++.NET? 7 147
best sources to up-to-date in C++? 8 115
parameter pack in c++11 2 23
Winapi.Windows.hpp problem 7 46
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 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