[squeak-dev] File creation time wrong on Mac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] File creation time wrong on Mac

stephane ducasse
Hi all

Is it a well-known bug that the creation time is incorrectly reported  
on Mac?


Time dateAndTimeFromSeconds:
(FileDirectory default
        directoryEntryFor: 'ESUG2008.txt') creationTime

It seems to be confused and return the last opened or last modified  
date.

Then is there a way to modify the creationTime and other  
characteristic of a file?

Stef

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] File creation time wrong on Mac

johnmci
Check the call where the primitive primitiveDirectoryLookup  
(FileDirectory default directoryContentsFor: )
is called that invokes the platform specific code in  
sqMacUnixFileInterface.c which has the code below

sqInt dir_Lookup(char *pathString, sqInt pathStringLength, sqInt index,
/* outputs: */  char *name, sqInt *nameLength, sqInt *creationDate,  
sqInt *modificationDate,
                sqInt *isDirectory, squeakFileOffsetType *sizeIfFile)

...
   /* last change time */
   *creationDate= convertToSqueakTime(statBuf.st_ctime);
   /* modification time */
   *modificationDate= convertToSqueakTime(statBuf.st_mtime);
...

where
/*
  * [XSI] This structure is used as the second parameter to the fstat(),
  * lstat(), and stat() functions.
  */
struct stat {
        dev_t st_dev; /* [XSI] ID of device containing file */
        ino_t   st_ino; /* [XSI] File serial number */
        mode_t st_mode; /* [XSI] Mode of file (see below) */
        nlink_t st_nlink; /* [XSI] Number of hard links */
        uid_t st_uid; /* [XSI] User ID of the file */
        gid_t st_gid; /* [XSI] Group ID of the file */
        dev_t st_rdev; /* [XSI] Device ID */
#ifndef _POSIX_C_SOURCE
        struct timespec st_atimespec; /* time of last access */
        struct timespec st_mtimespec; /* time of last data modification */
        struct timespec st_ctimespec; /* time of last status change */
#else
        time_t st_atime; /* [XSI] Time of last access */
        long st_atimensec; /* nsec of last access */
        time_t st_mtime; /* [XSI] Last data modification time */
        long st_mtimensec; /* last data modification nsec */
        time_t st_ctime; /* [XSI] Time of last status change */
        long st_ctimensec; /* nsec of last status change */
#endif
        off_t st_size; /* [XSI] file size, in bytes */
        blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
        blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
        __uint32_t st_flags; /* user defined flags for file */
        __uint32_t st_gen; /* file generation number */
        __int32_t st_lspare; /* RESERVED: DO NOT USE! */
        __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
};

The iPhone and new OSX version has

        *creationDate = convertToSqueakTime([fileAttributes objectForKey:  
NSFileCreationDate ]);
        *modificationDate = convertToSqueakTime([fileAttributes objectForKey:  
NSFileModificationDate]);


These seem correct but I don't have a test case handy.


On Jul 28, 2008, at 3:32 PM, stephane ducasse wrote:

> Hi all
>
> Is it a well-known bug that the creation time is incorrectly  
> reported on Mac?
>
>
> Time dateAndTimeFromSeconds:
> (FileDirectory default
> directoryEntryFor: 'ESUG2008.txt') creationTime
>
> It seems to be confused and return the last opened or last modified  
> date.
>
> Then is there a way to modify the creationTime and other  
> characteristic of a file?
>
> Stef
>

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================



Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: File creation time wrong on Mac

Paolo Bonzini-2
In reply to this post by stephane ducasse
> (FileDirectory default
>     directoryEntryFor: 'ESUG2008.txt') creationTime
>
> It seems to be confused and return the last opened or last modified date.

Unix filesystems don't store the creation time.

Paolo

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] File creation time wrong on Mac

stephane ducasse
In reply to this post by johnmci
Hi john

This is strange because I have some old pictures and I want to rename  
them based on their creation
time and not modification time. So I was really paying attention  
because I really do not want to
lose such information before my renaming (you know young kids....).
I will check with the latest mac VM.

John do you know if we can set also such information. So far I only  
find read only version
and I have pictures with no creation time but I know it and I would  
like to treat all my photos
to be independent of iPhoto metadata crap.

On Jul 28, 2008, at 11:31 PM, John M McIntosh wrote:

> Check the call where the primitive primitiveDirectoryLookup  
> (FileDirectory default directoryContentsFor: )
> is called that invokes the platform specific code in  
> sqMacUnixFileInterface.c which has the code below
>
> sqInt dir_Lookup(char *pathString, sqInt pathStringLength, sqInt  
> index,
> /* outputs: */  char *name, sqInt *nameLength, sqInt *creationDate,  
> sqInt *modificationDate,
> sqInt *isDirectory, squeakFileOffsetType *sizeIfFile)
>
> ...
> /* last change time */
> *creationDate= convertToSqueakTime(statBuf.st_ctime);
> /* modification time */
> *modificationDate= convertToSqueakTime(statBuf.st_mtime);
> ...
>
> where
> /*
> * [XSI] This structure is used as the second parameter to the fstat(),
> * lstat(), and stat() functions.
> */
> struct stat {
> dev_t st_dev; /* [XSI] ID of device containing file */
> ino_t   st_ino; /* [XSI] File serial number */
> mode_t st_mode; /* [XSI] Mode of file (see below) */
> nlink_t st_nlink; /* [XSI] Number of hard links */
> uid_t st_uid; /* [XSI] User ID of the file */
> gid_t st_gid; /* [XSI] Group ID of the file */
> dev_t st_rdev; /* [XSI] Device ID */
> #ifndef _POSIX_C_SOURCE
> struct timespec st_atimespec; /* time of last access */
> struct timespec st_mtimespec; /* time of last data modification */
> struct timespec st_ctimespec; /* time of last status change */
> #else
> time_t st_atime; /* [XSI] Time of last access */
> long st_atimensec; /* nsec of last access */
> time_t st_mtime; /* [XSI] Last data modification time */
> long st_mtimensec; /* last data modification nsec */
> time_t st_ctime; /* [XSI] Time of last status change */
> long st_ctimensec; /* nsec of last status change */
> #endif
> off_t st_size; /* [XSI] file size, in bytes */
> blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
> blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
> __uint32_t st_flags; /* user defined flags for file */
> __uint32_t st_gen; /* file generation number */
> __int32_t st_lspare; /* RESERVED: DO NOT USE! */
> __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
> };
>
> The iPhone and new OSX version has
>
> *creationDate = convertToSqueakTime([fileAttributes objectForKey:  
> NSFileCreationDate ]);
> *modificationDate = convertToSqueakTime([fileAttributes  
> objectForKey: NSFileModificationDate]);
>
>
> These seem correct but I don't have a test case handy.
>
>
> On Jul 28, 2008, at 3:32 PM, stephane ducasse wrote:
>
>> Hi all
>>
>> Is it a well-known bug that the creation time is incorrectly  
>> reported on Mac?
>>
>>
>> Time dateAndTimeFromSeconds:
>> (FileDirectory default
>> directoryEntryFor: 'ESUG2008.txt') creationTime
>>
>> It seems to be confused and return the last opened or last modified  
>> date.
>>
>> Then is there a way to modify the creationTime and other  
>> characteristic of a file?
>>
>> Stef
>>
>
> --
> =
> =
> =
> =
> =
> ======================================================================
> John M. McIntosh <[hidden email]>
> Corporate Smalltalk Consulting Ltd.  http://
> www.smalltalkconsulting.com
> =
> =
> =
> =
> =
> ======================================================================
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] File creation time wrong on Mac

David T. Lewis
On Tue, Jul 29, 2008 at 06:08:00PM +0200, stephane ducasse wrote:
> Hi john
>
> This is strange because I have some old pictures and I want to rename  
> them based on their creation
> time and not modification time. So I was really paying attention  
> because I really do not want to
> lose such information before my renaming (you know young kids....).
> I will check with the latest mac VM.

On a unix system (probably including OS X), "man 2 stat" gives an
explanation. If you have a picture file and have not modified it, the
creation time and modification time would be the same thing.

File systems are not platform independent. A "file" is just a metaphor,
and it means different things to different operating systems. And of
course to Squeak it does not need to mean very much at all, because Squeak
does not need such a metaphor :)

Dave