5113 |info type mode uid gid size id |
5113 |info type mode uid gid size id |
5114 atime mtime ctime |
5114 atime mtime ctime |
5115 aYr aMon aDay aHr aMin aSec aMS |
5115 aYr aMon aDay aHr aMin aSec aMS |
5116 mYr mMon mDay mHr mMin mSec mMS |
5116 mYr mMon mDay mHr mMin mSec mMS |
5117 cYr cMon cDay cHr cMin cSec cMS |
5117 cYr cMon cDay cHr cMin cSec cMS |
5118 fileName alternativeName path| |
5118 fileName alternativeName| |
5119 |
5119 |
5120 %{ |
5120 %{ |
5121 int ret; |
5121 int ret; |
5122 char alternativeFileNameBuffer[15]; |
5122 char alternativeFileNameBuffer[15]; |
5123 char fileNameBuffer[MAX_PATH+1]; |
5123 char fileNameBuffer[MAX_PATH+1]; |
5124 |
5124 |
5125 unsigned INT ino; |
5125 unsigned INT ino; |
5126 |
5126 |
5127 if (__isString(aPathName)) { |
5127 if (__isString(aPathName)) { |
5128 HANDLE hFile; |
5128 HANDLE hFile; |
5129 FILETIME tempFileTime; |
5129 FILETIME tempFileTime; |
5130 SYSTEMTIME creationTime; |
5130 SYSTEMTIME creationTime; |
5131 SYSTEMTIME accessTime; |
5131 SYSTEMTIME accessTime; |
5132 SYSTEMTIME modificationTime; |
5132 SYSTEMTIME modificationTime; |
5133 int modeBits = 0; |
5133 int modeBits = 0; |
5134 WIN32_FIND_DATA findStruct; |
5134 WIN32_FIND_DATA findStruct; |
5135 |
5135 |
5136 #ifdef DO_WRAP_CALLS |
5136 #ifdef DO_WRAP_CALLS |
5137 { |
5137 { |
5138 char _aPathName[MAXPATHLEN]; |
5138 char _aPathName[MAXPATHLEN]; |
5139 |
5139 |
5140 strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
5140 strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
5141 do { |
5141 do { |
5142 __threadErrno = 0; |
5142 __threadErrno = 0; |
5143 hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct); |
5143 hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct); |
5144 } while ((hFile < 0) && (__threadErrno == EINTR)); |
5144 } while ((hFile < 0) && (__threadErrno == EINTR)); |
5145 } |
5145 } |
5146 #else |
5146 #else |
5147 hFile = FindFirstFile(__stringVal(aPathName), &findStruct); |
5147 hFile = FindFirstFile(__stringVal(aPathName), &findStruct); |
5148 if (hFile < 0) { |
5148 if (hFile < 0) { |
5149 __threadErrno = __WIN32_ERR(GetLastError()); |
5149 __threadErrno = __WIN32_ERR(GetLastError()); |
5150 } |
5150 } |
5151 #endif |
5151 #endif |
5152 if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) { |
5152 if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) { |
5153 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
5153 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
5154 } else { |
5154 } else { |
5155 FindClose(hFile); |
5155 FindClose(hFile); |
5156 |
5156 |
5157 id = __mkSmallInteger(0); /* could get it by opening ... */ |
5157 id = __mkSmallInteger(0); /* could get it by opening ... */ |
5158 size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh); |
5158 size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh); |
5159 |
5159 |
5160 if (findStruct.cFileName[0] != '\0') { |
5160 if (findStruct.cFileName[0] != '\0') { |
5161 bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH); |
5161 bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH); |
5162 fileNameBuffer[MAX_PATH] = '\0'; |
5162 fileNameBuffer[MAX_PATH] = '\0'; |
5163 fileName = __MKSTRING(fileNameBuffer); /* FULL name */ |
5163 fileName = __MKSTRING(fileNameBuffer); /* FULL name */ |
5164 } |
5164 } |
5165 |
5165 |
5166 if (findStruct.cAlternateFileName[0] != '\0') { |
5166 if (findStruct.cAlternateFileName[0] != '\0') { |
5167 bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14); |
5167 bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14); |
5168 alternativeFileNameBuffer[14] = '\0'; |
5168 alternativeFileNameBuffer[14] = '\0'; |
5169 alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */ |
5169 alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */ |
5170 } |
5170 } |
5171 |
5171 |
5172 /* |
5172 /* |
5173 * simulate access bits |
5173 * simulate access bits |
5174 */ |
5174 */ |
5175 if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { |
5175 if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { |
5176 modeBits = 0444; |
5176 modeBits = 0444; |
5177 } else { |
5177 } else { |
5178 modeBits = 0666; |
5178 modeBits = 0666; |
5179 } |
5179 } |
5180 |
5180 |
5181 if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
5181 if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
5182 type = @symbol(directory); |
5182 type = @symbol(directory); |
5183 modeBits |= 0111; /* executable */ |
5183 modeBits |= 0111; /* executable */ |
5184 } else { |
5184 } else { |
5185 type = @symbol(regular); |
5185 type = @symbol(regular); |
5186 } |
5186 } |
5187 |
5187 |
5188 mode = __mkSmallInteger(modeBits); |
5188 mode = __mkSmallInteger(modeBits); |
5189 |
5189 |
5190 /* |
5190 /* |
5191 * sigh - convert from stupid time to useful time |
5191 * sigh - convert from stupid time to useful time |
5192 */ |
5192 */ |
5193 FileTimeToLocalFileTime(&findStruct.ftCreationTime, &tempFileTime); |
5193 FileTimeToLocalFileTime(&findStruct.ftCreationTime, &tempFileTime); |
5194 FileTimeToSystemTime(&tempFileTime, &creationTime); |
5194 FileTimeToSystemTime(&tempFileTime, &creationTime); |
5195 FileTimeToLocalFileTime(&findStruct.ftLastAccessTime, &tempFileTime); |
5195 FileTimeToLocalFileTime(&findStruct.ftLastAccessTime, &tempFileTime); |
5196 FileTimeToSystemTime(&tempFileTime, &accessTime); |
5196 FileTimeToSystemTime(&tempFileTime, &accessTime); |
5197 FileTimeToLocalFileTime(&findStruct.ftLastWriteTime, &tempFileTime); |
5197 FileTimeToLocalFileTime(&findStruct.ftLastWriteTime, &tempFileTime); |
5198 FileTimeToSystemTime(&tempFileTime, &modificationTime); |
5198 FileTimeToSystemTime(&tempFileTime, &modificationTime); |
5199 aYr = __mkSmallInteger(accessTime.wYear); |
5199 aYr = __mkSmallInteger(accessTime.wYear); |
5200 aMon = __mkSmallInteger(accessTime.wMonth); |
5200 aMon = __mkSmallInteger(accessTime.wMonth); |
5201 aDay = __mkSmallInteger(accessTime.wDay); |
5201 aDay = __mkSmallInteger(accessTime.wDay); |
5202 aHr = __mkSmallInteger(accessTime.wHour); |
5202 aHr = __mkSmallInteger(accessTime.wHour); |
5203 aMin = __mkSmallInteger(accessTime.wMinute); |
5203 aMin = __mkSmallInteger(accessTime.wMinute); |
5204 aSec = __mkSmallInteger(accessTime.wSecond); |
5204 aSec = __mkSmallInteger(accessTime.wSecond); |
5205 aMS = __mkSmallInteger(accessTime.wMilliseconds); |
5205 aMS = __mkSmallInteger(accessTime.wMilliseconds); |
5206 |
5206 |
5207 mYr = __mkSmallInteger(modificationTime.wYear); |
5207 mYr = __mkSmallInteger(modificationTime.wYear); |
5208 mMon = __mkSmallInteger(modificationTime.wMonth); |
5208 mMon = __mkSmallInteger(modificationTime.wMonth); |
5209 mDay = __mkSmallInteger(modificationTime.wDay); |
5209 mDay = __mkSmallInteger(modificationTime.wDay); |
5210 mHr = __mkSmallInteger(modificationTime.wHour); |
5210 mHr = __mkSmallInteger(modificationTime.wHour); |
5211 mMin = __mkSmallInteger(modificationTime.wMinute); |
5211 mMin = __mkSmallInteger(modificationTime.wMinute); |
5212 mSec = __mkSmallInteger(modificationTime.wSecond); |
5212 mSec = __mkSmallInteger(modificationTime.wSecond); |
5213 mMS = __mkSmallInteger(modificationTime.wMilliseconds); |
5213 mMS = __mkSmallInteger(modificationTime.wMilliseconds); |
5214 |
5214 |
5215 cYr = __mkSmallInteger(creationTime.wYear); |
5215 cYr = __mkSmallInteger(creationTime.wYear); |
5216 cMon = __mkSmallInteger(creationTime.wMonth); |
5216 cMon = __mkSmallInteger(creationTime.wMonth); |
5217 cDay = __mkSmallInteger(creationTime.wDay); |
5217 cDay = __mkSmallInteger(creationTime.wDay); |
5218 cHr = __mkSmallInteger(creationTime.wHour); |
5218 cHr = __mkSmallInteger(creationTime.wHour); |
5219 cMin = __mkSmallInteger(creationTime.wMinute); |
5219 cMin = __mkSmallInteger(creationTime.wMinute); |
5220 cSec = __mkSmallInteger(creationTime.wSecond); |
5220 cSec = __mkSmallInteger(creationTime.wSecond); |
5221 cMS = __mkSmallInteger(creationTime.wMilliseconds); |
5221 cMS = __mkSmallInteger(creationTime.wMilliseconds); |
5222 } |
5222 } |
5223 } |
5223 } |
5224 %}. |
5224 %}. |
5225 (aPathName endsWith:'.lnk') ifTrue:[ |
5225 (aPathName endsWith:'.lnk') ifTrue:[ |
5226 type := #symbolicLink. |
5226 type := #symbolicLink. |
5227 path := nil. |
5227 "/ now done lazyly in FileStatusInfo, when the path is accessed |
5228 "/ now done lazyly in FileStatusInfo, when the path is accessed |
5228 "/ path := self getLinkTarget:aPathName. |
5229 "/ path := self getLinkTarget:aPathName. |
|
5230 ]. |
5229 ]. |
5231 |
5230 |
5232 mode isNil ifTrue:[ |
5231 mode isNil ifTrue:[ |
5233 (self isDirectory:aPathName) ifTrue:[ |
5232 (self isDirectory:aPathName) ifTrue:[ |
5234 "/ the code above fails for root directories (these do not exist). |
5233 "/ the code above fails for root directories (these do not exist). |
5235 "/ simulate |
5234 "/ simulate |
5236 mode := 8r777. |
5235 mode := 8r777. |
5237 type := #directory. |
5236 type := #directory. |
5238 uid := gid := 0. |
5237 uid := gid := 0. |
5239 size := 0. |
5238 size := 0. |
5240 id := 0. |
5239 id := 0. |
5241 atime := mtime := ctime := Timestamp now. |
5240 atime := mtime := ctime := Timestamp now. |
5242 ]. |
5241 ]. |
5243 ]. |
5242 ]. |
5244 mode notNil ifTrue:[ |
5243 mode notNil ifTrue:[ |
5245 atime isNil ifTrue:[ |
5244 atime isNil ifTrue:[ |
5246 atime := Timestamp day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS. |
5245 atime := Timestamp day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS. |
5247 ]. |
5246 ]. |
5248 mtime isNil ifTrue:[ |
5247 mtime isNil ifTrue:[ |
5249 mtime := Timestamp day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS. |
5248 mtime := Timestamp day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS. |
5250 ]. |
5249 ]. |
5251 ctime isNil ifTrue:[ |
5250 ctime isNil ifTrue:[ |
5252 ctime := Timestamp day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS. |
5251 ctime := Timestamp day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS. |
5253 ]. |
5252 ]. |
5254 |
5253 |
5255 info := FileStatusInfo |
5254 info := FileStatusInfo |
5256 type:type |
5255 type:type |
5257 mode:mode |
5256 mode:mode |
5258 uid:uid |
5257 uid:uid |
5259 gid:gid |
5258 gid:gid |
5260 size:size |
5259 size:size |
5261 id:id |
5260 id:id |
5262 accessed:atime |
5261 accessed:atime |
5263 modified:mtime |
5262 modified:mtime |
5264 created:ctime |
5263 created:ctime |
5265 path:path |
5264 sourcePath:aPathName |
5266 fullName:fileName |
5265 fullName:fileName |
5267 alternativeName:alternativeName. |
5266 alternativeName:alternativeName. |
5268 ^ info |
5267 ^ info |
5269 ]. |
5268 ]. |
5270 ^ nil |
5269 ^ nil |
5271 |
5270 |
5272 " |
5271 " |
5273 OperatingSystem linkInfoOf:'c:\windows' |
5272 OperatingSystem linkInfoOf:'c:\windows' |