Can C pick up the timestamp of file 
Author Message
 Can C pick up the timestamp of file

What (if any) is the C function that tells you the time of creation of
a file?

Thanks!

Ellen



Fri, 30 Jun 2000 03:00:00 GMT  
 Can C pick up the timestamp of file


Quote:

>What (if any) is the C function that tells you the time of creation of
>a file?

There isn't one, so if you really need this, you have to look to some
platform specific extensions.


Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file

Quote:



>>What (if any) is the C function that tells you the time of creation of
>>a file?
>There isn't one, so if you really need this, you have to look to some
>platform specific extensions.

More than this, the operating  system  might  not  even  support  the
concept  of creation times on iles - for instance, Unix does not have
such a thing, so you cannot do it there.

Wolfgang Denk



Time is an illusion perpetrated by the manufacturers of space.



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file




: >>What (if any) is the C function that tells you the time of creation of
: >>a file?

: >There isn't one, so if you really need this, you have to look to some
: >platform specific extensions.

: More than this, the operating  system  might  not  even  support  the
: concept  of creation times on iles - for instance, Unix does not have
: such a thing, so you cannot do it there.

Never mind Unix, CP/M doesn't have any dates or times whatsoever; I'm
not sure if that permits a conforming compiler, come to that.  Does
a C compiler require a clock, or can all date/time functions return
00:00:00 1 Jan 70?

Will



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file

errrr... since when?  If you 'stat()' the file, you can use the ctime value
from the stat struct to get the last modified time - but that will be the
last 'touched' time of the file, not, strictly speaking, the creation time.



Quote:



> >>What (if any) is the C function that tells you the time of creation of
> >>a file?

> >There isn't one, so if you really need this, you have to look to some
> >platform specific extensions.

> More than this, the operating  system  might  not  even  support  the
> concept  of creation times on iles - for instance, Unix does not have
> such a thing, so you cannot do it there.

> Wolfgang Denk



> Time is an illusion perpetrated by the manufacturers of space.



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file


Quote:

>errrr... since when?  If you 'stat()' the file, you can use the ctime value
>from the stat struct to get the last modified time - but that will be the
>last 'touched' time of the file, not, strictly speaking, the creation time.

Haven't you just answered your own question?

John
--
John Winters.  Wallingford, Oxon, England.

Want to buy Linux CDs cheaply in the UK?  Join the Linux Buyers' Consortium.
See <http://www.polo.demon.co.uk/lbc.html>



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file

Quote:





>: >>What (if any) is the C function that tells you the time of creation of
>: >>a file?

>: >There isn't one, so if you really need this, you have to look to some
>: >platform specific extensions.

>: More than this, the operating  system  might  not  even  support  the
>: concept  of creation times on iles - for instance, Unix does not have
>: such a thing, so you cannot do it there.

>Never mind Unix, CP/M doesn't have any dates or times whatsoever; I'm
>not sure if that permits a conforming compiler, come to that.  Does
>a C compiler require a clock, or can all date/time functions return
>00:00:00 1 Jan 70?

The time() function returns "the implementation's best approximation to
the current calendar time", or (time_t)-1 if the calendar time is not
available.  So yes, an implementation that doesn't know the date could
be conforming.

Hmm, I wonder whether my implementation would be allowed to return,
"somewhere in the late 20th century" instead of (time_t)-1 if I argued
that that was its best approximation?

John
--
John Winters.  Wallingford, Oxon, England.

Want to buy Linux CDs cheaply in the UK?  Join the Linux Buyers' Consortium.
See <http://www.polo.demon.co.uk/lbc.html>



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file

Quote:





> : >>What (if any) is the C function that tells you the time of creation of
> : >>a file?

> : >There isn't one, so if you really need this, you have to look to some
> : >platform specific extensions.

> : More than this, the operating  system  might  not  even  support  the
> : concept  of creation times on iles - for instance, Unix does not have
> : such a thing, so you cannot do it there.

> Never mind Unix, CP/M doesn't have any dates or times whatsoever; I'm
> not sure if that permits a conforming compiler, come to that.  Does
> a C compiler require a clock, or can all date/time functions return
> 00:00:00 1 Jan 70?

  Umm... they must return time, but it is not stated, that this
time must be a correct one :)

        Regards,
                Alex Krol



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file



Quote:
>errrr... since when?  If you 'stat()' the file, you can use the ctime value
>from the stat struct to get the last modified time - but that will be the
>last 'touched' time of the file, not, strictly speaking, the creation time.

In fact it has nothing to do with the file creation time. All you can
determine from it is: "the file was created not later than this time".
A better approximation is st_mtime but that still isn't a creation time -
Unix doesn't support one.

--
-----------------------------------------


-----------------------------------------



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file


Quote:

> > More than this, the operating  system  might  not  even  support  the
> > concept  of creation times on iles - for instance, Unix does not have
> > such a thing, so you cannot do it there.
> errrr... since when?  If you 'stat()' the file, you can use the ctime value
> from the stat struct to get the last modified time - but that will be the
> last 'touched' time of the file, not, strictly speaking, the creation time.

In other words, just as Wolfgang said, Unix does not keep creation times.

--
In general, it is safe and legal to kill your children and their children.
    -- POSIX Programmer's Manual



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file

Quote:

> What (if any) is the C function that tells you the time of creation of
> a file?

Hi Ellen Paik,

There is no such function in standard C. And indeed the availability
of this information depends highly on the operating/host system
being used. Most compilers do offer compiler specific (ie. non
portable) function(s) to support access to file properties. In most
Unix C compilers there is a function called "stat()", some DOS/Windows
compilers have a "fstat()" function, etc. Please browse the manual
of your compiler to find out if it supports this functionality.

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Sat, 01 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file

Quote:

>> What (if any) is the C function that tells you the time of creation of
>> a file?
>There is no such function in standard C. And indeed the availability
>of this information depends highly on the operating/host system
>being used. Most compilers do offer compiler specific (ie. non
>portable) function(s) to support access to file properties. In most
>Unix C compilers there is a function called "stat()", some DOS/Windows
>compilers have a "fstat()" function, etc. Please browse the manual
>of your compiler to find out if it supports this functionality.

Just so. To take this inherently non-portable issue a little further,
it is often easier to look at the definition of FILE in stdio.h, rather
than grope through an alhabetically organized manual (stat? fstat?
dos_fstat?...).

best wishes, mark s.



Wed, 05 Jul 2000 03:00:00 GMT  
 Can C pick up the timestamp of file



Quote:

>>> What (if any) is the C function that tells you the time of creation of
>>> a file?

>>There is no such function in standard C. And indeed the availability
>>of this information depends highly on the operating/host system
>>being used. Most compilers do offer compiler specific (ie. non
>>portable) function(s) to support access to file properties. In most
>>Unix C compilers there is a function called "stat()", some DOS/Windows
>>compilers have a "fstat()" function, etc. Please browse the manual
>>of your compiler to find out if it supports this functionality.

>Just so. To take this inherently non-portable issue a little further,
>it is often easier to look at the definition of FILE in stdio.h, rather
>than grope through an alhabetically organized manual (stat? fstat?
>dos_fstat?...).

Doing so probably won't help much and may even mislead. FILE structures tend
to contain the information that is required to support a stream which
doesn't typically include things like file names or timestamps. Even if you
find the information you want in a FILE structure it tells you nothing about
the correct way to access that information *on that particular platform*.
Even if what you want to do isn't covered by ANSI C it may be covered by
other standard that the platform support or even just platform specific
documentation. For example one of that platforms I use (A Unix/POSIX
platform) defines FILE in <stdio.h> with a __file member holding the
underluying file descriptor that the sream is attached to. Writing things
like fp->__file in code would be *wrong*, POSIX defines a fileno() function
for this purpose that will work acroos all POSIX systems. It will continue
to work when the next version of the compiler changes the members of the
FILE structure e.g. renames them.

It is sometimes useful to examine headers, but only as a step in locating
the right documentation, or for debugging purposes.

--
-----------------------------------------


-----------------------------------------



Fri, 07 Jul 2000 03:00:00 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. Beginner [Q] Using Canned File Open/Save dialog

3. Change file -> change timestamp of file

4. File selector which picks file and folders

5. resx files needed for cs - files ??

6. CS files display in VS6 like CPP files ?

7. New contrib file for UPS debugger.

8. finding file creation timestamp

9. get file timestamp

10. File timestamps in C

11. verifying symbol files timestamps

12. Get/Set file timestamp

 

 
Powered by phpBB® Forum Software