Solved

File Details.

Posted on 2000-02-28
7
221 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
  • 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

809 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