165 # ifdef __DEF_Process |
167 # ifdef __DEF_Process |
166 # define Process __DEF_Process |
168 # define Process __DEF_Process |
167 # endif |
169 # endif |
168 # ifdef __DEF_Processor |
170 # ifdef __DEF_Processor |
169 # define Processor __DEF_Processor |
171 # define Processor __DEF_Processor |
|
172 # endif |
|
173 # ifdef __DEF_String |
|
174 # define String __DEF_String |
|
175 # endif |
|
176 # ifdef __DEF_Character |
|
177 # define Character __DEF_Character |
170 # endif |
178 # endif |
171 |
179 |
172 # define INT int |
180 # define INT int |
173 # define UINT uint |
181 # define UINT uint |
174 # define off_t long |
182 # define off_t long |
2447 "{ Pragma: +optSpace }" |
2455 "{ Pragma: +optSpace }" |
2448 |
2456 |
2449 |exClass| |
2457 |exClass| |
2450 |
2458 |
2451 exClass := (errorNumber == (OperatingSystem errorNumberFor:#ERROR_FILE_NOT_FOUND)) |
2459 exClass := (errorNumber == (OperatingSystem errorNumberFor:#ERROR_FILE_NOT_FOUND)) |
2452 ifTrue:[ FileDoesNotExistException ] |
2460 ifTrue:[ FileDoesNotExistException ] |
2453 ifFalse:[ OpenError ]. |
2461 ifFalse:[ OpenError ]. |
2454 |
2462 |
2455 ^ exClass newException |
2463 ^ exClass newException |
2456 errorCode:errorNumber; |
2464 errorCode:errorNumber; |
2457 "/ cg: initialized lazyly - see #description in OpenError |
2465 "/ cg: initialized lazyly - see #description in OpenError |
2458 "/ errorString:(' : ' , (OperatingSystem errorTextForNumber:errorNumber)); |
2466 "/ errorString:(' : ' , (OperatingSystem errorTextForNumber:errorNumber)); |
2459 parameter:self; |
2467 parameter:self; |
2460 raiseRequest |
2468 raiseRequest |
2461 "/ in:thisContext sender |
2469 "/ in:thisContext sender |
2462 |
2470 |
2463 "Modified: / 09-09-2011 / 07:22:49 / cg" |
2471 "Modified: / 09-09-2011 / 07:22:49 / cg" |
2464 ! |
2472 ! |
2465 |
2473 |
2466 readError |
2474 readError |
3865 ^ self readError. |
3873 ^ self readError. |
3866 ! |
3874 ! |
3867 |
3875 |
3868 nextWord |
3876 nextWord |
3869 "in text-mode: |
3877 "in text-mode: |
3870 read the alphaNumeric next word (i.e. up to non letter-or-digit). |
3878 read the alphaNumeric next word (i.e. up to non letter-or-digit). |
3871 return a string containing those characters. |
3879 return a string containing those characters. |
3872 in binary-mode: |
3880 in binary-mode: |
3873 read two bytes (msb-first) and return the value as a 16-bit |
3881 read two bytes (msb-first) and return the value as a 16-bit |
3874 unsigned Integer (for compatibility with other smalltalks)" |
3882 unsigned Integer (for compatibility with other smalltalks)" |
3875 |
3883 |
3876 binary ifTrue:[ |
3884 binary ifTrue:[ |
3877 ^ self nextUnsignedShortMSB:true |
3885 ^ self nextUnsignedShortMSB:true |
3878 ]. |
3886 ]. |
3879 self obsoleteMethodWarning:'use #nextAlphaNumericWord'. |
3887 self obsoleteMethodWarning:'use #nextAlphaNumericWord'. |
3880 ^ self nextAlphaNumericWord |
3888 ^ self nextAlphaNumericWord |
3881 ! ! |
3889 ! ! |
3882 |
3890 |
4432 if (__isStringLike(aPath) && __isStringLike(openModeString)) { |
4440 if (__isStringLike(aPath) && __isStringLike(openModeString)) { |
4433 #ifdef WIN32 |
4441 #ifdef WIN32 |
4434 # if 1 |
4442 # if 1 |
4435 f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString)); |
4443 f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString)); |
4436 # else |
4444 # else |
4437 __BEGIN_INTERRUPTABLE__ |
4445 __BEGIN_INTERRUPTABLE__ |
4438 do { |
4446 do { |
4439 f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString)); |
4447 f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString)); |
4440 } while ((f == NULL) && (__threadErrno == EINTR)); |
4448 } while ((f == NULL) && (__threadErrno == EINTR)); |
4441 __END_INTERRUPTABLE__ |
4449 __END_INTERRUPTABLE__ |
4442 # endif |
4450 # endif |
4443 #else /* UNIX */ |
4451 #else /* UNIX */ |
4444 __BEGIN_INTERRUPTABLE__ |
4452 __BEGIN_INTERRUPTABLE__ |
4445 do { |
4453 do { |
4446 f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString)); |
4454 f = fopen((char *) __stringVal(aPath), (char *) __stringVal(openModeString)); |
4447 } while ((f == NULL) && (__threadErrno == EINTR)); |
4455 } while ((f == NULL) && (__threadErrno == EINTR)); |
4448 __END_INTERRUPTABLE__ |
4456 __END_INTERRUPTABLE__ |
4449 #endif /* UNIX */ |
4457 #endif /* UNIX */ |
4450 if (f == NULL) { |
4458 if (f == NULL) { |
4451 __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno); |
4459 __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno); |
4452 } else { |
4460 } else { |
4453 if (@global(FileOpenTrace) == true) { |
4461 if (@global(FileOpenTrace) == true) { |
4454 fprintf(stderr, "fopen %s [ExternalStream] -> %x\n", __stringVal(aPath), f); |
4462 fprintf(stderr, "fopen %s [ExternalStream] -> %x\n", __stringVal(aPath), f); |
4455 } |
4463 } |
4456 fp = __MKFILEPOINTER(f); __INST(handle) = fp; __STORE(self, fp); |
4464 fp = __MKFILEPOINTER(f); __INST(handle) = fp; __STORE(self, fp); |
4457 __INST(handleType) = @symbol(filePointer); |
4465 __INST(handleType) = @symbol(filePointer); |
4458 ok = true; |
4466 ok = true; |
4459 } |
4467 } |
4460 } |
4468 } |
4461 %}. |
4469 %}. |
4462 ok ifFalse:[ |
4470 ok ifFalse:[ |
4463 " |
4471 " |
4464 the open failed for some reason ... |
4472 the open failed for some reason ... |
4465 " |
4473 " |
4466 ^ self openError:lastErrorNumber. |
4474 ^ self openError:lastErrorNumber. |
4467 ]. |
4475 ]. |
4468 position := ZeroPosition. |
4476 position := ZeroPosition. |
4469 Lobby register:self. |
4477 Lobby register:self. |
4470 ! |
4478 ! |
4471 |
4479 |
5693 ! ! |
5701 ! ! |
5694 |
5702 |
5695 !ExternalStream class methodsFor:'documentation'! |
5703 !ExternalStream class methodsFor:'documentation'! |
5696 |
5704 |
5697 version |
5705 version |
5698 ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.353 2012-12-17 19:37:33 cg Exp $' |
5706 ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.354 2013-01-08 17:55:11 cg Exp $' |
5699 ! |
5707 ! |
5700 |
5708 |
5701 version_CVS |
5709 version_CVS |
5702 ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.353 2012-12-17 19:37:33 cg Exp $' |
5710 ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.354 2013-01-08 17:55:11 cg Exp $' |
5703 ! ! |
5711 ! ! |
5704 |
5712 |
5705 |
5713 |
5706 ExternalStream initialize! |
5714 ExternalStream initialize! |