AbstractFileBrowser.st
changeset 5973 0baf6c6b685f
parent 5971 af337e1a857f
child 5977 66af015a4a18
equal deleted inserted replaced
5972:ba002e258fd9 5973:0baf6c6b685f
  6140 
  6140 
  6141 getFileInfoStringForFirstSelectedFile:longInfo
  6141 getFileInfoStringForFirstSelectedFile:longInfo
  6142     "get stat info on selected file - return a string which can be
  6142     "get stat info on selected file - return a string which can be
  6143      shown in a box"
  6143      shown in a box"
  6144 
  6144 
  6145     |selFiles filename fileOutput type modeBits modeString s isLink info 
  6145     |selFiles filename fileOutput modeBits modeString s info
  6146      sizeString fileSize tAccess tModification buffer|
  6146      sizeString fileSize tAccess tModification buffer|
  6147 
  6147 
  6148     selFiles := self currentFileNameHolder value.
  6148     selFiles := self currentFileNameHolder value.
  6149     selFiles size ~~ 1 ifTrue:[ ^ nil].
  6149     selFiles size ~~ 1 ifTrue:[ ^ nil].
  6150     filename := selFiles first.
  6150     filename := selFiles first.
  6153 
  6153 
  6154     buffer 
  6154     buffer 
  6155         nextPutAll:'filename: '; 
  6155         nextPutAll:'filename: '; 
  6156         nextPutLine:filename asString.
  6156         nextPutLine:filename asString.
  6157 
  6157 
  6158     isLink := filename isSymbolicLink.
       
  6159 
       
  6160     buffer nextPutAll:'type:   '.
  6158     buffer nextPutAll:'type:   '.
  6161 
  6159 
  6162     info := filename info.
  6160     info := filename linkInfo.
  6163     isLink ifTrue:[
  6161     info isSymbolicLink ifTrue:[
  6164         info isNil ifTrue:[
  6162         filename exists ifFalse:[
  6165             buffer nextPutAll:'broken '.
  6163             buffer nextPutAll:'broken '.
  6166         ].
  6164         ].
  6167         buffer 
  6165         buffer 
  6168             nextPutAll:'symbolic link to: ';
  6166             nextPutAll:'symbolic link to: ';
  6169             nextPutLine:(filename linkInfo path).
  6167             nextPutLine:info path.
  6170     ] ifFalse:[
  6168     ] ifFalse:[
  6171         type := info type.
  6169         (longInfo and:[info isRegular]) ifTrue:[
  6172         (longInfo and:[type == #regular]) ifTrue:[
       
  6173             fileOutput := filename fileType.
  6170             fileOutput := filename fileType.
  6174         ].
  6171         ].
  6175 
  6172 
  6176         fileOutput isNil ifTrue:[
  6173         fileOutput isNil ifTrue:[
  6177             s := type asString
  6174             s := info type asString
  6178         ] ifFalse:[
  6175         ] ifFalse:[
  6179             s := 'regular (' , fileOutput , ')'
  6176             s := 'regular (' , fileOutput , ')'
  6180         ].
  6177         ].
  6181         buffer nextPutLine:s.
  6178         buffer nextPutLine:s.
  6182     ].
  6179     ].
  6183 
  6180 
  6184     isLink = true ifTrue:[
       
  6185         info := filename linkInfo
       
  6186     ] ifFalse:[
       
  6187         info := filename info
       
  6188     ].
       
  6189     
       
  6190     fileSize := info fileSize.
  6181     fileSize := info fileSize.
  6191     sizeString := 'size:   ', fileSize printString.
  6182     sizeString := 'size:   ', fileSize printString.
  6192     longInfo ifTrue:[
  6183     longInfo ifTrue:[
  6193         fileSize > 1024  ifTrue:[
  6184         fileSize > 1024  ifTrue:[
  6194             sizeString := sizeString , ' (' , ((fileSize / 1024) asFixedPoint:1) printString , ' K'.
  6185             sizeString := sizeString , ' (' , ((fileSize / 1024) asFixedPoint:1) printString , ' K'.
  6203     modeBits := info mode.
  6194     modeBits := info mode.
  6204     modeString := self getModeString:modeBits.
  6195     modeString := self getModeString:modeBits.
  6205 
  6196 
  6206     buffer nextPutAll:'access: '; nextPutAll:modeString.
  6197     buffer nextPutAll:'access: '; nextPutAll:modeString.
  6207     longInfo ifTrue:[
  6198     longInfo ifTrue:[
  6208         buffer space; nextPutAll:(modeBits printStringRadix:8).
  6199         buffer nextPutAll:' ('; nextPutAll:(modeBits printStringRadix:8); nextPut:$).
  6209     ].
  6200     ].
  6210     buffer
  6201     buffer
  6211         cr;
  6202         cr;
  6212         nextPutAll:'owner:  ';
  6203         nextPutAll:'owner:  ';
  6213         nextPutLine:(OperatingSystem getUserNameFromID:(info uid)).
  6204         nextPutLine:(OperatingSystem getUserNameFromID:(info uid)).
  6218             nextPutLine:(OperatingSystem getGroupNameFromID:(info gid)).
  6209             nextPutLine:(OperatingSystem getGroupNameFromID:(info gid)).
  6219 
  6210 
  6220         tAccess := info accessTime.
  6211         tAccess := info accessTime.
  6221         buffer 
  6212         buffer 
  6222             nextPutAll:'last access:       '; 
  6213             nextPutAll:'last access:       '; 
  6223             nextPutAll:tAccess asTime printString;
  6214             nextPutAll:tAccess asDate printString; 
  6224             space;
  6215             space;
  6225             nextPutLine:tAccess asDate printString. 
  6216             nextPutLine:tAccess asTime printString.
  6226 
  6217 
  6227         tModification := info modificationTime.
  6218         tModification := info modificationTime.
  6228         buffer 
  6219         buffer 
  6229             nextPutAll:'last modification:       '; 
  6220             nextPutAll:'last modification: '; 
  6230             nextPutAll:tModification asTime printString;
  6221             nextPutAll:tModification asDate printString; 
  6231             space;
  6222             space;
  6232             nextPutLine:tModification asDate printString. 
  6223             nextPutLine:tModification asTime printString.
  6233     ].
  6224     ].
  6234     ^ buffer contents
  6225     ^ buffer contents
  6235 !
  6226 !
  6236 
  6227 
  6237 initialCommandFor:fileName into:aBox
  6228 initialCommandFor:fileName into:aBox
  6912 ! !
  6903 ! !
  6913 
  6904 
  6914 !AbstractFileBrowser class methodsFor:'documentation'!
  6905 !AbstractFileBrowser class methodsFor:'documentation'!
  6915 
  6906 
  6916 version
  6907 version
  6917     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.250 2004-08-12 09:22:19 stefan Exp $'
  6908     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.251 2004-08-13 19:27:06 stefan Exp $'
  6918 ! !
  6909 ! !