5161 Notice that the returned number is OS dependent - use the |
5161 Notice that the returned number is OS dependent - use the |
5162 modeMasks as returned by OperatingSystem>>accessMaskFor:" |
5162 modeMasks as returned by OperatingSystem>>accessMaskFor:" |
5163 |
5163 |
5164 " |
5164 " |
5165 this could have been implemented as: |
5165 this could have been implemented as: |
5166 (self infoOf:aPathName) at:#mode |
5166 (self infoOf:aPathName) at:#mode |
5167 but for huge directory searches the code below is faster |
5167 but for huge directory searches the code below is faster |
5168 " |
5168 " |
|
5169 |
|
5170 |error| |
5169 |
5171 |
5170 %{ |
5172 %{ |
5171 struct stat buf; |
5173 struct stat buf; |
5172 int ret; |
5174 int ret; |
5173 |
5175 |
5174 if (__isStringLike(aPathName)) { |
5176 if (__isStringLike(aPathName)) { |
5175 #ifdef DO_WRAP_CALLS |
5177 #ifdef DO_WRAP_CALLS |
5176 char _aPathName[MAXPATHLEN]; |
5178 char _aPathName[MAXPATHLEN]; |
5177 |
5179 |
5178 strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
5180 strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
5179 |
5181 |
5180 do { |
5182 do { |
5181 __threadErrno = 0; |
5183 __threadErrno = 0; |
5182 // do not cast to INT - will loose sign bit then! |
5184 // do not cast to INT - will loose sign bit then! |
5183 ret = STX_C_NOINT_CALL2( "_stat", _stat, _aPathName, &buf); |
5185 ret = STX_C_NOINT_CALL2( "_stat", _stat, _aPathName, &buf); |
5184 } while ((ret < 0) && (__threadErrno == EINTR)); |
5186 } while ((ret < 0) && (__threadErrno == EINTR)); |
5185 #else |
5187 #else |
5186 __BEGIN_INTERRUPTABLE__ |
5188 __BEGIN_INTERRUPTABLE__ |
5187 do { |
5189 do { |
5188 __threadErrno = 0; |
5190 __threadErrno = 0; |
5189 ret = _stat( (char *)__stringVal(aPathName), &buf); |
5191 ret = _stat( (char *)__stringVal(aPathName), &buf); |
5190 } while ((ret < 0) && (__threadErrno == EINTR)); |
5192 } while ((ret < 0) && (__threadErrno == EINTR)); |
5191 __END_INTERRUPTABLE__ |
5193 __END_INTERRUPTABLE__ |
5192 if (ret < 0) { |
5194 if (ret < 0) { |
5193 __threadErrno = __WIN32_ERR(GetLastError()); |
5195 __threadErrno = __WIN32_ERR(GetLastError()); |
5194 } |
5196 } |
5195 #endif |
5197 #endif |
5196 if (ret < 0) { |
|
5197 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
|
5198 RETURN ( nil ); |
|
5199 } |
|
5200 RETURN ( __mkSmallInteger(buf.st_mode & 0777) ); |
|
5201 } else if (__isUnicode16String(aPathName)) { |
5198 } else if (__isUnicode16String(aPathName)) { |
5202 #ifdef DO_WRAP_CALLS |
5199 #ifdef DO_WRAP_CALLS |
5203 char _wPathName[MAXPATHLEN]; |
5200 char _wPathName[MAXPATHLEN]; |
5204 |
5201 |
5205 _makeWchar(aPathName, _wPathName, sizeof(_wPathName)); |
5202 _makeWchar(aPathName, _wPathName, sizeof(_wPathName)); |
5206 |
5203 |
5207 do { |
5204 do { |
5208 __threadErrno = 0; |
5205 __threadErrno = 0; |
5209 // do not cast to INT - will loose sign bit then! |
5206 // do not cast to INT - will loose sign bit then! |
5210 ret = STX_C_NOINT_CALL2( "_wstat", _wstat, _wPathName, &buf); |
5207 ret = STX_C_NOINT_CALL2( "_wstat", _wstat, _wPathName, &buf); |
5211 } while ((ret < 0) && (__threadErrno == EINTR)); |
5208 } while ((ret < 0) && (__threadErrno == EINTR)); |
5212 #else |
5209 #else |
5213 __BEGIN_INTERRUPTABLE__ |
5210 __BEGIN_INTERRUPTABLE__ |
5214 do { |
5211 do { |
5215 __threadErrno = 0; |
5212 __threadErrno = 0; |
5216 ret = _wstat((char *)__unicode16StringVal(aPathName), &buf); |
5213 ret = _wstat((char *)__unicode16StringVal(aPathName), &buf); |
5217 } while ((ret < 0) && (__threadErrno == EINTR)); |
5214 } while ((ret < 0) && (__threadErrno == EINTR)); |
5218 __END_INTERRUPTABLE__ |
5215 __END_INTERRUPTABLE__ |
5219 if (ret < 0) { |
5216 if (ret < 0) { |
5220 __threadErrno = __WIN32_ERR(GetLastError()); |
5217 __threadErrno = __WIN32_ERR(GetLastError()); |
5221 } |
5218 } |
5222 #endif |
5219 #endif |
5223 if (ret < 0) { |
5220 } else |
5224 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
5221 goto out; |
5225 RETURN ( nil ); |
5222 |
5226 } |
5223 if (ret >= 0) { |
5227 RETURN ( __mkSmallInteger(buf.st_mode & 0777) ); |
5224 RETURN ( __mkSmallInteger(buf.st_mode & 0777) ); |
5228 } |
5225 } |
|
5226 error = __mkSmallInteger(__threadErrno); |
|
5227 out:; |
5229 %}. |
5228 %}. |
5230 ^ self primitiveFailed |
5229 |
|
5230 error notNil ifTrue:[ |
|
5231 LastErrorNumber := error. |
|
5232 ^ self errorHolderForNumber:error. |
|
5233 ]. |
|
5234 |
|
5235 ^ self primitiveFailed |
5231 |
5236 |
5232 " |
5237 " |
5233 (OperatingSystem accessModeOf:'/') printStringRadix:8 |
5238 (OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
5239 (OperatingSystem accessModeOf:'foo') printStringRadix:8 |
5234 (OperatingSystem accessModeOf:'Make.proto') printStringRadix:8 |
5240 (OperatingSystem accessModeOf:'Make.proto') printStringRadix:8 |
5235 (OperatingSystem changeAccessModeOf:'Make.proto' to:8r644) |
5241 (OperatingSystem changeAccessModeOf:'foo' to:8r644) |
5236 'Make.proto' asUnicode16String asFilename accessRights printStringRadix:8 |
5242 'Make.proto' asUnicode16String asFilename accessRights printStringRadix:8 |
5237 " |
5243 " |
5238 ! |
5244 ! |
5239 |
5245 |
5240 accessModeOfFd:aFileDescriptor |
5246 accessModeOfFd:aFileDescriptor |
5243 Notice that the returned number is OS dependent - use the |
5249 Notice that the returned number is OS dependent - use the |
5244 modeMasks as returned by OperatingSystem>>accessMaskFor:" |
5250 modeMasks as returned by OperatingSystem>>accessMaskFor:" |
5245 |
5251 |
5246 " |
5252 " |
5247 this could have been implemented as: |
5253 this could have been implemented as: |
5248 (self infoOf:aPathName) at:#mode |
5254 (self infoOf:aPathName) at:#mode |
5249 but for huge directory searches the code below is faster |
5255 but for huge directory searches the code below is faster |
5250 " |
5256 " |
|
5257 |
|
5258 |error| |
5251 |
5259 |
5252 %{ |
5260 %{ |
5253 struct stat buf; |
5261 struct stat buf; |
5254 int ret; |
5262 int ret; |
5255 |
5263 |
5256 if (__isSmallInteger(aFileDescriptor)) { |
5264 if (__isSmallInteger(aFileDescriptor)) { |
5257 #ifdef DO_WRAP_CALLS |
5265 #ifdef DO_WRAP_CALLS |
5258 do { |
5266 do { |
5259 __threadErrno = 0; |
5267 __threadErrno = 0; |
5260 // do not cast to INT - will loose sign bit then! |
5268 // do not cast to INT - will loose sign bit then! |
5261 ret = STX_C_NOINT_CALL2( "fstat", fstat, __smallIntegerVal(aFileDescriptor), &buf); |
5269 ret = STX_C_NOINT_CALL2( "fstat", fstat, __smallIntegerVal(aFileDescriptor), &buf); |
5262 } while ((ret < 0) && (__threadErrno == EINTR)); |
5270 } while ((ret < 0) && (__threadErrno == EINTR)); |
5263 #else |
5271 #else |
5264 __BEGIN_INTERRUPTABLE__ |
5272 __BEGIN_INTERRUPTABLE__ |
5265 do { |
5273 do { |
5266 __threadErrno = 0; |
5274 __threadErrno = 0; |
5267 // do not cast to INT - will loose sign bit then! |
5275 // do not cast to INT - will loose sign bit then! |
5268 ret = fstat( __smallIntegerVal(aFileDescriptor), &buf); |
5276 ret = fstat( __smallIntegerVal(aFileDescriptor), &buf); |
5269 } while ((ret < 0) && (__threadErrno == EINTR)); |
5277 } while ((ret < 0) && (__threadErrno == EINTR)); |
5270 __END_INTERRUPTABLE__ |
5278 __END_INTERRUPTABLE__ |
5271 if (ret < 0) { |
5279 if (ret < 0) { |
5272 __threadErrno = __WIN32_ERR(GetLastError()); |
5280 __threadErrno = __WIN32_ERR(GetLastError()); |
5273 } |
5281 } |
5274 #endif |
5282 #endif |
5275 |
5283 } else |
5276 if (ret < 0) { |
5284 goto out; |
5277 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
5285 |
5278 RETURN ( nil ); |
5286 if (ret >= 0) { |
5279 } |
5287 RETURN ( __mkSmallInteger(buf.st_mode & 0777) ); |
5280 RETURN ( __mkSmallInteger(buf.st_mode & 0777) ); |
5288 } |
5281 } |
5289 error = __mkSmallInteger(__threadErrno); |
|
5290 out:; |
5282 %}. |
5291 %}. |
5283 ^ self primitiveFailed |
5292 |
|
5293 error notNil ifTrue:[ |
|
5294 LastErrorNumber := error. |
|
5295 ^ self errorHolderForNumber:error. |
|
5296 ]. |
|
5297 ^ self primitiveFailed |
5284 |
5298 |
5285 " |
5299 " |
5286 'c:\windows' asFilename readingFileDo:[:s| |
5300 'c:\windows' asFilename readingFileDo:[:s| |
5287 (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8. |
5301 (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8. |
5288 ]. |
5302 ]. |
5289 'Make.proto' asFilename readingFileDo:[:s| |
5303 'Make.proto' asFilename readingFileDo:[:s| |
5290 (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8. |
5304 (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8. |
5291 ]. |
5305 ]. |
5292 (OperatingSystem changeAccessModeOf:'Make.proto' to:8r644) |
5306 (OperatingSystem changeAccessModeOf:'Make.proto' to:8r644) |
5293 " |
5307 " |
5294 ! |
5308 ! |
5295 |
5309 |