--- a/UnixOperatingSystem.st Wed Jan 30 13:22:07 2002 +0100
+++ b/UnixOperatingSystem.st Fri Feb 01 10:56:56 2002 +0100
@@ -34,7 +34,8 @@
!
Object subclass:#FileStatusInfo
- instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path'
+ instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
+ numLinks'
classVariableNames:''
poolDictionaries:''
privateIn:UnixOperatingSystem
@@ -4931,21 +4932,21 @@
"return some object filled with info for the file 'aPathName';
the info (for which corresponding access methods are understood by
the returned object) is:
- type - a symbol giving the files type
- mode - numeric access mode
- uid - owners user id
- gid - owners group id
- size - files size
- id - files number (i.e. inode number)
- accessed - last access time (as Timestamp)
- modified - last modification time (as Timestamp)
- statusChanged - last status change time (as Timestamp)
- alternativeName - (windows only:) the MSDOS name of the file
- recordFormatNumeric - (VMS only:) numeric value of the recordFormat
- recordFormat - (VMS only:) symbolic value of the recordFormat
- recordAttributes - (VMS only:) recordAttributes
- fixedHeaderSize - (VMS only:) fixed header size in a variable record format
- recordSize - (VMS only:) record size.
+ type - a symbol giving the files type
+ mode - numeric access mode
+ uid - owners user id
+ gid - owners group id
+ size - files size
+ id - files number (i.e. inode number)
+ accessed - last access time (as Timestamp)
+ modified - last modification time (as Timestamp)
+ statusChanged - last status change time (as Timestamp)
+ alternativeName - (windows only:) the MSDOS name of the file
+ recordFormatNumeric - (VMS only:) numeric value of the recordFormat
+ recordFormat - (VMS only:) symbolic value of the recordFormat
+ recordAttributes - (VMS only:) recordAttributes
+ fixedHeaderSize - (VMS only:) fixed header size in a variable record format
+ recordSize - (VMS only:) record size.
Some of the fields may be returned as nil on systems which do not provide
all of the information.
@@ -4955,7 +4956,7 @@
use #linkInfoOf: to get info about the link itself.
"
- |info type mode uid gid size id
+ |info type mode uid gid size id nLink
atime mtime ctime
aOStime mOStime cOStime|
%{
@@ -4965,95 +4966,97 @@
if (__isString(aPathName)) {
# ifdef TRACE_STAT_CALLS
- printf("stat on '%s' for info\n", __stringVal(aPathName));
-# endif
- __BEGIN_INTERRUPTABLE__
- do {
- ret = stat((char *) __stringVal(aPathName), &buf);
- } while ((ret < 0) && (errno == EINTR));
- __END_INTERRUPTABLE__
-
- if (ret < 0) {
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- RETURN ( nil );
- }
- switch (buf.st_mode & S_IFMT) {
- case S_IFDIR:
- type = @symbol(directory);
- break;
-
- case S_IFREG:
- type = @symbol(regular);
- break;
+ printf("stat on '%s' for info\n", __stringVal(aPathName));
+# endif
+ __BEGIN_INTERRUPTABLE__
+ do {
+ ret = stat((char *) __stringVal(aPathName), &buf);
+ } while ((ret < 0) && (errno == EINTR));
+ __END_INTERRUPTABLE__
+
+ if (ret < 0) {
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ RETURN ( nil );
+ }
+ switch (buf.st_mode & S_IFMT) {
+ case S_IFDIR:
+ type = @symbol(directory);
+ break;
+
+ case S_IFREG:
+ type = @symbol(regular);
+ break;
# ifdef S_IFCHR
- case S_IFCHR:
- type = @symbol(characterSpecial);
- break;
+ case S_IFCHR:
+ type = @symbol(characterSpecial);
+ break;
# endif
# ifdef S_IFBLK
- case S_IFBLK:
- type = @symbol(blockSpecial);
- break;
+ case S_IFBLK:
+ type = @symbol(blockSpecial);
+ break;
# endif
# ifdef S_IFMPC
- case S_IFMPC:
- type = @symbol(multiplexedCharacterSpecial);
- break;
+ case S_IFMPC:
+ type = @symbol(multiplexedCharacterSpecial);
+ break;
# endif
# ifdef S_IFMPB
- case S_IFMPB:
- type = @symbol(multiplexedBlockSpecial);
- break;
+ case S_IFMPB:
+ type = @symbol(multiplexedBlockSpecial);
+ break;
# endif
# ifdef S_IFLNK
- case S_IFLNK:
- type = @symbol(symbolicLink);
- break;
+ case S_IFLNK:
+ type = @symbol(symbolicLink);
+ break;
# endif
# ifdef S_IFSOCK
- case S_IFSOCK:
- type = @symbol(socket);
- break;
+ case S_IFSOCK:
+ type = @symbol(socket);
+ break;
# endif
# ifdef S_IFIFO
- case S_IFIFO:
- type = @symbol(fifo);
- break;
-# endif
- default:
- type = @symbol(unknown);
- break;
- }
-
- ino = buf.st_ino;
- id = __MKUINT(ino);
-
- mode = __MKSMALLINT(buf.st_mode & 0777);
- uid = __MKSMALLINT(buf.st_uid);
- gid = __MKSMALLINT(buf.st_gid);
- size = __MKUINT(buf.st_size);
- aOStime = __MKUINT(buf.st_atime);
- mOStime = __MKUINT(buf.st_mtime);
- cOStime = __MKUINT(buf.st_ctime);
+ case S_IFIFO:
+ type = @symbol(fifo);
+ break;
+# endif
+ default:
+ type = @symbol(unknown);
+ break;
+ }
+
+ ino = buf.st_ino;
+ id = __MKUINT(ino);
+
+ mode = __MKSMALLINT(buf.st_mode & 0777);
+ uid = __MKSMALLINT(buf.st_uid);
+ gid = __MKSMALLINT(buf.st_gid);
+ nLink = __MKSMALLINT(buf.st_nlink);
+ size = __MKUINT(buf.st_size);
+ aOStime = __MKUINT(buf.st_atime);
+ mOStime = __MKUINT(buf.st_mtime);
+ cOStime = __MKUINT(buf.st_ctime);
}
%}.
mode notNil ifTrue:[
- atime := AbsoluteTime fromOSTime:(aOStime * 1000).
- mtime := AbsoluteTime fromOSTime:(mOStime * 1000).
- ctime := AbsoluteTime fromOSTime:(cOStime * 1000).
-
- info := FileStatusInfo
- type:type
- mode:mode
- uid:uid
- gid:gid
- size:size
- id:id
- accessed:atime
- modified:mtime
- statusChanged:ctime
- path:nil.
- ^ info
+ atime := AbsoluteTime fromOSTime:(aOStime * 1000).
+ mtime := AbsoluteTime fromOSTime:(mOStime * 1000).
+ ctime := AbsoluteTime fromOSTime:(cOStime * 1000).
+
+ info := FileStatusInfo
+ type:type
+ mode:mode
+ uid:uid
+ gid:gid
+ size:size
+ id:id
+ accessed:atime
+ modified:mtime
+ statusChanged:ctime
+ path:nil
+ numLinks:nLink.
+ ^ info
].
^ self primitiveFailed
@@ -5225,7 +5228,7 @@
on contrast to #infoOf:, which returns the info of the pointed to file
in case of a symbolic link."
- |info type mode uid gid size id atime mtime ctime path|
+ |info type mode uid gid size id nLink atime mtime ctime path|
%{ /* STACK: 1200 */
#if defined(S_IFLNK)
@@ -5235,59 +5238,61 @@
unsigned INT ino;
if (__isString(aPathName)) {
- __BEGIN_INTERRUPTABLE__
- do {
- ret = lstat((char *) __stringVal(aPathName), &buf);
- } while ((ret < 0) && (errno == EINTR));
- __END_INTERRUPTABLE__
-
- if (ret < 0) {
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- RETURN ( nil );
- }
- switch (buf.st_mode & S_IFMT) {
- default:
- RETURN ( nil ); /* not a symbolic link */
-
- case S_IFLNK:
- type = @symbol(symbolicLink);
- break;
- }
-
- ino = buf.st_ino;
- id = __MKUINT(ino);
-
- mode = __MKSMALLINT(buf.st_mode & 0777);
- uid = __MKSMALLINT(buf.st_uid);
- gid = __MKSMALLINT(buf.st_gid);
- size = __MKUINT(buf.st_size);
- atime = __MKUINT(buf.st_atime);
- mtime = __MKUINT(buf.st_mtime);
- ctime = __MKUINT(buf.st_ctime);
- if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- RETURN ( nil );
- }
- pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */
- path = __MKSTRING(pathBuffer);
+ __BEGIN_INTERRUPTABLE__
+ do {
+ ret = lstat((char *) __stringVal(aPathName), &buf);
+ } while ((ret < 0) && (errno == EINTR));
+ __END_INTERRUPTABLE__
+
+ if (ret < 0) {
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ RETURN ( nil );
+ }
+ switch (buf.st_mode & S_IFMT) {
+ default:
+ RETURN ( nil ); /* not a symbolic link */
+
+ case S_IFLNK:
+ type = @symbol(symbolicLink);
+ break;
+ }
+
+ ino = buf.st_ino;
+ id = __MKUINT(ino);
+
+ mode = __MKSMALLINT(buf.st_mode & 0777);
+ nLink = __MKSMALLINT(buf.st_nlink);
+ uid = __MKSMALLINT(buf.st_uid);
+ gid = __MKSMALLINT(buf.st_gid);
+ size = __MKUINT(buf.st_size);
+ atime = __MKUINT(buf.st_atime);
+ mtime = __MKUINT(buf.st_mtime);
+ ctime = __MKUINT(buf.st_ctime);
+ if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ RETURN ( nil );
+ }
+ pathBuffer[ret] = '\0'; /* readlink does not 0-terminate */
+ path = __MKSTRING(pathBuffer);
}
#else
RETURN ( nil );
#endif
%}.
mode notNil ifTrue:[
- info := IdentityDictionary new.
- ^ FileStatusInfo
- type:type
- mode:mode
- uid:uid
- gid:gid
- size:size
- id:id
- accessed:(AbsoluteTime fromOSTime:(atime * 1000))
- modified:(AbsoluteTime fromOSTime:(mtime * 1000))
- statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
- path:path
+ info := IdentityDictionary new.
+ ^ FileStatusInfo
+ type:type
+ mode:mode
+ uid:uid
+ gid:gid
+ size:size
+ id:id
+ accessed:(AbsoluteTime fromOSTime:(atime * 1000))
+ modified:(AbsoluteTime fromOSTime:(mtime * 1000))
+ statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
+ path:path
+ numLinks:nLink.
].
^ self primitiveFailed
@@ -10403,7 +10408,7 @@
!UnixOperatingSystem::FilePointerHandle class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.112 2002-01-15 15:20:44 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.113 2002-02-01 09:56:56 cg Exp $'
! !
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
@@ -10424,13 +10429,19 @@
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
+type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
^ self basicNew
- type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
+ type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
! !
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
+accessTime
+ "return accessed"
+
+ ^ accessed
+!
+
accessed
"return accessed"
@@ -10444,6 +10455,12 @@
^ nil
!
+fileSize
+ "return size"
+
+ ^ size
+!
+
fixedHeaderSize
"return the fixedHeaderSize (VMS only; nil everywhere else)"
@@ -10468,12 +10485,24 @@
^ mode
!
+modificationTime
+ "return modified"
+
+ ^ modified
+!
+
modified
"return modified"
^ modified
!
+numLinks
+ "return numLinks"
+
+ ^ numLinks
+!
+
path
"for symbolic links only: return the path where the symbolic link points to"
@@ -10541,7 +10570,7 @@
!UnixOperatingSystem::FileStatusInfo methodsFor:'private accessing'!
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
+type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
type := t.
mode := m.
uid := u.
@@ -10552,6 +10581,7 @@
modified := mT.
statusChanged := sT.
path := lP.
+ numLinks := nL.
! !
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
@@ -11992,6 +12022,6 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.112 2002-01-15 15:20:44 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.113 2002-02-01 09:56:56 cg Exp $'
! !
UnixOperatingSystem initialize!