[BUG][Unix] ctime and mtime entries swapped in DirectoryEntry

Lex Spoon lex at cc.gatech.edu
Wed Oct 22 16:39:14 UTC 2003


Ned Konz <ned at bike-nomad.com> wrote:


> >         atime - modified when file is opened for read, or via utime()
> >         mtime - modified when file is opened for write, or via utime()
> >         ctime - modified when file is opened for write, or when any
> >                 metadata is changed (renamed, linked, utime'd, chowned,
> 
> Right. And what I was seeing in Squeak is that it was reporting the ctime 
> rather than the mtime.

Hmm, maybe it's okay.  What exactly is the "modification time", anyway,
that Squeak asks for?  Does it include modifications to metadata?  It at
least seems defensible that changing, say, the name of the file, is a
"modification" of the file.

On a side note, it's sad that Squeak asks for creation time even though
this platform cannot provide it.  If anyone revamps the FileDirectory
hierarchy, this is something to think about: either creation time needs
to go, or it needs to be optional.  Reporting the mtime for this field
is kind weird.

Anyway, it's marked as intentional in the source code, though the
rationale is not listed.  Relevant code appended. -Lex

====

static int entryArrayForfromStatBuf(int fileName, struct stat * statBuf) {
    int creationDate;
    int isDirectory;
    int sizeIfFile;
    int modificationDate;


	/* Use status change time instead */

	creationDate = smalltalkSecondsFromPosixSeconds(statBuf->st_mtime);
	modificationDate = smalltalkSecondsFromPosixSeconds(statBuf->st_ctime);
	if ((S_ISDIR(statBuf->st_mode)) == 0) {
		isDirectory = 0;
		sizeIfFile = statBuf->st_size;
	} else {
		isDirectory = 1;
		sizeIfFile = 0;
	}
	return makeDirEntryNamecreateDatemodDateisDirfileSize(fileName, creationDate, modificationDate, isDirectory, sizeIfFile);
}



More information about the Squeak-dev mailing list