For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2007 > Using Perl Win 32 AS 5.8.x - Anyway to find the File Create Date/Time









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 Using Perl Win 32 AS 5.8.x - Anyway to find the File Create Date/Time
Wagner, David --- Senior Programmer Analyst --- WG

2007-09-14, 6:59 pm

stat will give me the mod time, but does not have the create
time. From Windows Explorer, I notice that I can get the Create Date.

Anyway to accomplish this in Perl? I did a search against CPAN
and also AS, but what I put in ( Perl create time file ) did not seem to
give me what I was looking for.

Any ideas?
=09
Thanks.

Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449 FAX
http://fedex.com/us=20


****************************************
******************************
This message contains information that is confidential and proprietary to F=
edEx Freight or its affiliates. It is intended only for the recipient name=
d and for the express purpose(s) described therein. Any other use is proh=
ibited.
****************************************
******************************

Jenda Krynicky

2007-09-17, 7:00 pm

From: "Wagner, David --- Senior Programmer Analyst --- WGO"
<David.Wagner@freight.fedex.com>
> stat will give me the mod time, but does not have the create
> time. From Windows Explorer, I notice that I can get the Create Date.



perldoc -f stat

stat FILEHANDLE
stat EXPR
stat Returns a 13-element list giving the status info for a file,
either the file opened via FILEHANDLE, or named by EXPR. If
EXPR
is omitted, it stats $_. Returns a null list if the stat
fails.
Typically used as follows:

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,
$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);

Not all fields are supported on all filesystem types. Here
are
the meanings of the fields:

0 dev device number of filesystem
1 ino inode number
2 mode file mode (type and permissions)
3 nlink number of (hard) links to the file
4 uid numeric user ID of file's owner
5 gid numeric group ID of file's owner
6 rdev the device identifier (special files only)
7 size total size of file, in bytes
8 atime last access time in seconds since the epoch
9 mtime last modify time in seconds since the epoch
10 ctime inode change time in seconds since the epoch (*)
11 blksize preferred block size for file system I/O
12 blocks actual number of blocks allocated

(The epoch was at 00:00 January 1, 1970 GMT.)

(*) Not all fields are supported on all filesystem types.
Notably, the ctime field is non-portable. In particular, you
cannot expect it to be a "creation time", see "Files and
Filesystems" in perlport for details.

The docs are still pretty Unix-centric it seems. "inode change time"
.... lovely. In particular, under Windows, this is the creation time.



perldoc perlport
...
stat
Platforms that do not have rdev, blksize, or blocks will return
these as '', so numeric comparison or manipulation of these fields
may cause 'not numeric' warnings.

- mtime and atime are the same thing, and ctime is creation time
instead of inode change time. (Mac OS).

- ctime not supported on UFS (Mac OS X).

- ctime is creation time instead of inode change time (Win32).
....


Jenda
P.S.: Guys, when was the last time you wanted to know the "inode
change time"? Looks to me like this is just a case of "bug claimed to
be a feature" that Microsoft is otherwise famous for. stat() was
supposed to return the creation time, but someone failed to notice
inodes can change, and instead of fixing the issue and giving the
users what they ask for the docs were updated and the bug was turned
into a feature.
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

Rob Dixon

2007-09-17, 10:00 pm

Wagner, David --- Senior Programmer Analyst --- WGO wrote:
>
> stat will give me the mod time, but does not have the create
> time. From Windows Explorer, I notice that I can get the Create Date.
>
> Anyway to accomplish this in Perl? I did a search against CPAN
> and also AS, but what I put in ( Perl create time file ) did not seem to
> give me what I was looking for.
>
> Any ideas?


Hi David

It's

(stat $file)[10]

that you want, as Jenda has pointed out. But it's
also worth noting that this is the same as

-C $file

HTH,

Rob
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com