--- a/DirStr.st Wed Aug 04 16:12:09 1999 +0200
+++ b/DirStr.st Wed Aug 04 16:13:11 1999 +0200
@@ -578,22 +578,22 @@
ok = false;
if (__INST(dirPointer) == nil) {
- path = __INST(pathName);
- if (__isString(path)) {
- __BEGIN_INTERRUPTABLE__
- errno = 0;
- do {
- d = opendir((char *) __stringVal(path));
- } while ((d == NULL) && (errno == EINTR));
- __END_INTERRUPTABLE__
+ path = __INST(pathName);
+ if (__isString(path)) {
+ __BEGIN_INTERRUPTABLE__
+ errno = 0;
+ do {
+ d = opendir((char *) __stringVal(path));
+ } while ((d == NULL) && (errno == EINTR));
+ __END_INTERRUPTABLE__
- if (d == NULL) {
- __INST(lastErrorNumber) = __MKSMALLINT(errno);
- } else {
- __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
- ok = true;
- }
- }
+ if (d == NULL) {
+ __INST(lastErrorNumber) = __MKSMALLINT(errno);
+ } else {
+ __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
+ ok = true;
+ }
+ }
}
#else
# ifdef WIN32
@@ -604,48 +604,48 @@
ok = false;
if (__INST(dirPointer) == nil) {
- path = __INST(pathName);
- if (__isString(path)) {
- int l = __stringSize(path);
+ path = __INST(pathName);
+ if (__isString(path)) {
+ int l = __stringSize(path);
- if (l < (sizeof(pattern)-4)) {
- strncpy(pattern, __stringVal(path), l);
- strcpy(pattern+l, "\\*");
+ if (l < (sizeof(pattern)-4)) {
+ strncpy(pattern, __stringVal(path), l);
+ strcpy(pattern+l, "\\*");
# ifdef DO_WRAP_CALLS
- d = __STX_API_CALL2( (void*)FindFirstFile, (void *)pattern, (void *)&data );
+ d = __STX_API_CALL2( (void*)FindFirstFile, (void *)pattern, (void *)&data );
# else
- d = FindFirstFile(pattern, &data);
+ d = FindFirstFile(pattern, &data);
# endif
- if (d == INVALID_HANDLE_VALUE) {
- __INST(lastErrorNumber) = __MKSMALLINT(GetLastError());
- } else {
- __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
- entry = __MKSTRING( data.cFileName );
- ok = true;
- }
- }
- }
+ if (d == INVALID_HANDLE_VALUE) {
+ __INST(lastErrorNumber) = __MKSMALLINT(GetLastError());
+ } else {
+ __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
+ entry = __MKSTRING( data.cFileName );
+ ok = true;
+ }
+ }
+ }
}
# endif
#endif
%}.
ok isNil ifTrue:[
- "
- opendir not avalable - use slower pipe
- "
- ^ PipeStream readingFrom:('cd ' , pathName , '; ls -a')
+ "
+ opendir not avalable - use slower pipe
+ "
+ ^ PipeStream readingFrom:('cd ' , pathName , '; ls -a')
].
(ok == true) ifTrue:[
- Lobby register:self.
- entry isNil ifTrue:[
- self nextLine. "read 1st entry into readAheadEntry buffer"
- ] ifFalse:[
- readAheadEntry := entry.
- ].
- ^ self
+ Lobby register:self.
+ entry isNil ifTrue:[
+ self nextLine. "read 1st entry into readAheadEntry buffer"
+ ] ifFalse:[
+ readAheadEntry := entry.
+ ].
+ ^ self
].
- dirPointer notNil ifTrue:[^ self errorOpen].
+ dirPointer notNil ifTrue:[^ self errorAlreadyOpen].
lastErrorNumber notNil ifTrue:[^ self openError].
^ nil
!
@@ -691,5 +691,5 @@
!DirectoryStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/DirStr.st,v 1.47 1999-06-18 12:49:29 ps Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/DirStr.st,v 1.48 1999-08-04 14:13:11 cg Exp $'
! !
--- a/DirectoryStream.st Wed Aug 04 16:12:09 1999 +0200
+++ b/DirectoryStream.st Wed Aug 04 16:13:11 1999 +0200
@@ -578,22 +578,22 @@
ok = false;
if (__INST(dirPointer) == nil) {
- path = __INST(pathName);
- if (__isString(path)) {
- __BEGIN_INTERRUPTABLE__
- errno = 0;
- do {
- d = opendir((char *) __stringVal(path));
- } while ((d == NULL) && (errno == EINTR));
- __END_INTERRUPTABLE__
+ path = __INST(pathName);
+ if (__isString(path)) {
+ __BEGIN_INTERRUPTABLE__
+ errno = 0;
+ do {
+ d = opendir((char *) __stringVal(path));
+ } while ((d == NULL) && (errno == EINTR));
+ __END_INTERRUPTABLE__
- if (d == NULL) {
- __INST(lastErrorNumber) = __MKSMALLINT(errno);
- } else {
- __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
- ok = true;
- }
- }
+ if (d == NULL) {
+ __INST(lastErrorNumber) = __MKSMALLINT(errno);
+ } else {
+ __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
+ ok = true;
+ }
+ }
}
#else
# ifdef WIN32
@@ -604,48 +604,48 @@
ok = false;
if (__INST(dirPointer) == nil) {
- path = __INST(pathName);
- if (__isString(path)) {
- int l = __stringSize(path);
+ path = __INST(pathName);
+ if (__isString(path)) {
+ int l = __stringSize(path);
- if (l < (sizeof(pattern)-4)) {
- strncpy(pattern, __stringVal(path), l);
- strcpy(pattern+l, "\\*");
+ if (l < (sizeof(pattern)-4)) {
+ strncpy(pattern, __stringVal(path), l);
+ strcpy(pattern+l, "\\*");
# ifdef DO_WRAP_CALLS
- d = __STX_API_CALL2( (void*)FindFirstFile, (void *)pattern, (void *)&data );
+ d = __STX_API_CALL2( (void*)FindFirstFile, (void *)pattern, (void *)&data );
# else
- d = FindFirstFile(pattern, &data);
+ d = FindFirstFile(pattern, &data);
# endif
- if (d == INVALID_HANDLE_VALUE) {
- __INST(lastErrorNumber) = __MKSMALLINT(GetLastError());
- } else {
- __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
- entry = __MKSTRING( data.cFileName );
- ok = true;
- }
- }
- }
+ if (d == INVALID_HANDLE_VALUE) {
+ __INST(lastErrorNumber) = __MKSMALLINT(GetLastError());
+ } else {
+ __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
+ entry = __MKSTRING( data.cFileName );
+ ok = true;
+ }
+ }
+ }
}
# endif
#endif
%}.
ok isNil ifTrue:[
- "
- opendir not avalable - use slower pipe
- "
- ^ PipeStream readingFrom:('cd ' , pathName , '; ls -a')
+ "
+ opendir not avalable - use slower pipe
+ "
+ ^ PipeStream readingFrom:('cd ' , pathName , '; ls -a')
].
(ok == true) ifTrue:[
- Lobby register:self.
- entry isNil ifTrue:[
- self nextLine. "read 1st entry into readAheadEntry buffer"
- ] ifFalse:[
- readAheadEntry := entry.
- ].
- ^ self
+ Lobby register:self.
+ entry isNil ifTrue:[
+ self nextLine. "read 1st entry into readAheadEntry buffer"
+ ] ifFalse:[
+ readAheadEntry := entry.
+ ].
+ ^ self
].
- dirPointer notNil ifTrue:[^ self errorOpen].
+ dirPointer notNil ifTrue:[^ self errorAlreadyOpen].
lastErrorNumber notNil ifTrue:[^ self openError].
^ nil
!
@@ -691,5 +691,5 @@
!DirectoryStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.47 1999-06-18 12:49:29 ps Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.48 1999-08-04 14:13:11 cg Exp $'
! !
--- a/ExtStream.st Wed Aug 04 16:12:09 1999 +0200
+++ b/ExtStream.st Wed Aug 04 16:13:11 1999 +0200
@@ -1510,6 +1510,18 @@
^ self error:'argument must be a string'
!
+errorAlreadyOpen
+ "{ Pragma: +optSpace }"
+
+ "report an error, that the stream is already opened"
+
+ ^ self class openErrorSignal
+ raiseRequestWith:self
+ errorString:(self class name , ' is already open')
+
+ "Modified: / 8.5.1999 / 20:12:30 / cg"
+!
+
errorBinary
"{ Pragma: +optSpace }"
@@ -1562,19 +1574,6 @@
"Modified: / 8.5.1999 / 20:12:33 / cg"
!
-errorOpen
- "{ Pragma: +optSpace }"
-
- "report an error, that the stream is already opened"
-
- ^ self openErrorSignal
- raiseRequestWith:self
- errorString:(self class name , ' is already open')
- "/ in:thisContext sender
-
- "Modified: / 8.5.1999 / 20:12:30 / cg"
-!
-
errorReadOnly
"{ Pragma: +optSpace }"
@@ -3333,7 +3332,7 @@
|retVal|
- filePointer notNil ifTrue:[^ self errorOpen].
+ filePointer notNil ifTrue:[^ self errorAlreadyOpen].
%{
FILEPOINTER f;
OBJ fp;
@@ -3341,26 +3340,26 @@
if (__isSmallInteger(aFileDescriptor)
&& (__qClass(openmode)== @global(String))) {
- f = (FILEPOINTER) fdopen(__intVal(aFileDescriptor), (char *)__stringVal(openmode));
- if (f == NULL) {
- __INST(lastErrorNumber) = __MKSMALLINT(errno);
- __INST(position) = nil;
- } else {
- __INST(filePointer) = fp = __MKFILEPOINTER(f); __STORE(self, fp);
- __INST(position) = __MKSMALLINT(1);
- retVal = self;
- }
+ f = (FILEPOINTER) fdopen(__intVal(aFileDescriptor), (char *)__stringVal(openmode));
+ if (f == NULL) {
+ __INST(lastErrorNumber) = __MKSMALLINT(errno);
+ __INST(position) = nil;
+ } else {
+ __INST(filePointer) = fp = __MKFILEPOINTER(f); __STORE(self, fp);
+ __INST(position) = __MKSMALLINT(1);
+ retVal = self;
+ }
}
%}.
retVal notNil ifTrue:[
- buffered := true. "default is buffered"
- Lobby register:self
+ buffered := true. "default is buffered"
+ Lobby register:self
].
lastErrorNumber notNil ifTrue:[
- "
- the open failed for some reason ...
- "
- ^ self openError
+ "
+ the open failed for some reason ...
+ "
+ ^ self openError
].
^ retVal
!
@@ -4868,6 +4867,6 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.195 1999-07-30 18:06:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/ExtStream.st,v 1.196 1999-08-04 14:12:48 cg Exp $'
! !
ExternalStream initialize!
--- a/ExternalStream.st Wed Aug 04 16:12:09 1999 +0200
+++ b/ExternalStream.st Wed Aug 04 16:13:11 1999 +0200
@@ -1510,6 +1510,18 @@
^ self error:'argument must be a string'
!
+errorAlreadyOpen
+ "{ Pragma: +optSpace }"
+
+ "report an error, that the stream is already opened"
+
+ ^ self class openErrorSignal
+ raiseRequestWith:self
+ errorString:(self class name , ' is already open')
+
+ "Modified: / 8.5.1999 / 20:12:30 / cg"
+!
+
errorBinary
"{ Pragma: +optSpace }"
@@ -1562,19 +1574,6 @@
"Modified: / 8.5.1999 / 20:12:33 / cg"
!
-errorOpen
- "{ Pragma: +optSpace }"
-
- "report an error, that the stream is already opened"
-
- ^ self openErrorSignal
- raiseRequestWith:self
- errorString:(self class name , ' is already open')
- "/ in:thisContext sender
-
- "Modified: / 8.5.1999 / 20:12:30 / cg"
-!
-
errorReadOnly
"{ Pragma: +optSpace }"
@@ -3333,7 +3332,7 @@
|retVal|
- filePointer notNil ifTrue:[^ self errorOpen].
+ filePointer notNil ifTrue:[^ self errorAlreadyOpen].
%{
FILEPOINTER f;
OBJ fp;
@@ -3341,26 +3340,26 @@
if (__isSmallInteger(aFileDescriptor)
&& (__qClass(openmode)== @global(String))) {
- f = (FILEPOINTER) fdopen(__intVal(aFileDescriptor), (char *)__stringVal(openmode));
- if (f == NULL) {
- __INST(lastErrorNumber) = __MKSMALLINT(errno);
- __INST(position) = nil;
- } else {
- __INST(filePointer) = fp = __MKFILEPOINTER(f); __STORE(self, fp);
- __INST(position) = __MKSMALLINT(1);
- retVal = self;
- }
+ f = (FILEPOINTER) fdopen(__intVal(aFileDescriptor), (char *)__stringVal(openmode));
+ if (f == NULL) {
+ __INST(lastErrorNumber) = __MKSMALLINT(errno);
+ __INST(position) = nil;
+ } else {
+ __INST(filePointer) = fp = __MKFILEPOINTER(f); __STORE(self, fp);
+ __INST(position) = __MKSMALLINT(1);
+ retVal = self;
+ }
}
%}.
retVal notNil ifTrue:[
- buffered := true. "default is buffered"
- Lobby register:self
+ buffered := true. "default is buffered"
+ Lobby register:self
].
lastErrorNumber notNil ifTrue:[
- "
- the open failed for some reason ...
- "
- ^ self openError
+ "
+ the open failed for some reason ...
+ "
+ ^ self openError
].
^ retVal
!
@@ -4868,6 +4867,6 @@
!ExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.195 1999-07-30 18:06:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.196 1999-08-04 14:12:48 cg Exp $'
! !
ExternalStream initialize!
--- a/FileStr.st Wed Aug 04 16:12:09 1999 +0200
+++ b/FileStr.st Wed Aug 04 16:13:11 1999 +0200
@@ -738,7 +738,7 @@
|ok|
- filePointer notNil ifTrue:[^ self errorOpen].
+ filePointer notNil ifTrue:[^ self errorAlreadyOpen].
ok := false.
%{
FILE *f;
@@ -750,205 +750,205 @@
path = __INST(pathName);
if (__isNonNilObject(path) && (__qClass(path)==String)) {
#ifdef __VMS__
- do {
- /*
- * allow passing additional RMS arguments.
- * stupid: DEC does not seem to offer an interface for passing a char **.
- */
- errno = 0;
+ do {
+ /*
+ * allow passing additional RMS arguments.
+ * stupid: DEC does not seem to offer an interface for passing a char **.
+ */
+ errno = 0;
- {
- if (__isArray(attributeSpec)) {
- OBJ *ap = __ArrayInstPtr(attributeSpec)->a_element;
- int numAttrib = 0;
- int i;
+ {
+ if (__isArray(attributeSpec)) {
+ OBJ *ap = __ArrayInstPtr(attributeSpec)->a_element;
+ int numAttrib = 0;
+ int i;
- numAttrib = __arraySize(attributeSpec);
- for (i=0; i<numAttrib;i++) {
- if (! __isString(ap[i])) {
- f = NULL;
- errno = EINVAL; /* invalid argument */
- goto getOutOfHere;
- }
- }
- switch (numAttrib) {
- case 0:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode));
- __END_INTERRUPTABLE__
- break;
- case 1:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]));
- __END_INTERRUPTABLE__
- break;
- case 2:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]));
- __END_INTERRUPTABLE__
- break;
- case 3:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]));
- __END_INTERRUPTABLE__
- break;
- case 4:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]));
- __END_INTERRUPTABLE__
- break;
- case 5:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]));
- __END_INTERRUPTABLE__
- break;
- case 6:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]));
- __END_INTERRUPTABLE__
- break;
- case 7:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]));
- __END_INTERRUPTABLE__
- break;
- case 8:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]), __stringVal(ap[7]));
- __END_INTERRUPTABLE__
- break;
- case 9:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]));
- __END_INTERRUPTABLE__
- break;
- case 10:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]),
- __stringVal(ap[9]));
- __END_INTERRUPTABLE__
- break;
- default:
- f = NULL;
- errno = E2BIG; /* too many args */
- goto getOutOfHere;
- }
- } else if (attributeSpec != nil) {
- f = NULL;
- errno = EINVAL; /* invalid argument */
- goto getOutOfHere;
- } else {
- /*
- * create file as sequential streamLF by default.
- */
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode), "rfm=stmlf");
- __END_INTERRUPTABLE__
- }
- }
- /* must refetch - could be GC'd */
- path = __INST(pathName);
- } while ((f == NULL) && (errno == EINTR));
+ numAttrib = __arraySize(attributeSpec);
+ for (i=0; i<numAttrib;i++) {
+ if (! __isString(ap[i])) {
+ f = NULL;
+ errno = EINVAL; /* invalid argument */
+ goto getOutOfHere;
+ }
+ }
+ switch (numAttrib) {
+ case 0:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode));
+ __END_INTERRUPTABLE__
+ break;
+ case 1:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]));
+ __END_INTERRUPTABLE__
+ break;
+ case 2:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]));
+ __END_INTERRUPTABLE__
+ break;
+ case 3:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]));
+ __END_INTERRUPTABLE__
+ break;
+ case 4:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]));
+ __END_INTERRUPTABLE__
+ break;
+ case 5:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]));
+ __END_INTERRUPTABLE__
+ break;
+ case 6:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]));
+ __END_INTERRUPTABLE__
+ break;
+ case 7:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]));
+ __END_INTERRUPTABLE__
+ break;
+ case 8:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]), __stringVal(ap[7]));
+ __END_INTERRUPTABLE__
+ break;
+ case 9:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]));
+ __END_INTERRUPTABLE__
+ break;
+ case 10:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]),
+ __stringVal(ap[9]));
+ __END_INTERRUPTABLE__
+ break;
+ default:
+ f = NULL;
+ errno = E2BIG; /* too many args */
+ goto getOutOfHere;
+ }
+ } else if (attributeSpec != nil) {
+ f = NULL;
+ errno = EINVAL; /* invalid argument */
+ goto getOutOfHere;
+ } else {
+ /*
+ * create file as sequential streamLF by default.
+ */
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode), "rfm=stmlf");
+ __END_INTERRUPTABLE__
+ }
+ }
+ /* must refetch - could be GC'd */
+ path = __INST(pathName);
+ } while ((f == NULL) && (errno == EINTR));
#else
- do {
- __BEGIN_INTERRUPTABLE__
+ do {
+ __BEGIN_INTERRUPTABLE__
# ifdef LINUX
- /*
- * LINUX may ret a non-NULL f even when interrupted.
- * Therefore, check errno and fake a null-ret.
- */
- errno = 0;
- f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
- if (errno == EINTR)
- f = NULL;
+ /*
+ * LINUX may ret a non-NULL f even when interrupted.
+ * Therefore, check errno and fake a null-ret.
+ */
+ errno = 0;
+ f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
+ if (errno == EINTR)
+ f = NULL;
# else
- f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
+ f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
# endif
- __END_INTERRUPTABLE__
- /* must refetch - could be GC'd */
- path = __INST(pathName);
- } while ((f == NULL) && (errno == EINTR));
+ __END_INTERRUPTABLE__
+ /* must refetch - could be GC'd */
+ path = __INST(pathName);
+ } while ((f == NULL) && (errno == EINTR));
#endif
- if (f == NULL) {
- /*
- * If no filedescriptors available, try to finalize
- * possibly collected fd's and try again.
- */
- if (pass == 0 && (errno == ENFILE || errno == EMFILE)) {
- pass = 1;
- __SSEND0(@global(ObjectMemory), @symbol(scavenge), 0);
- __SSEND0(@global(ObjectMemory), @symbol(finalize), 0);
- goto retry;
- }
- getOutOfHere: ;
- __INST(lastErrorNumber) = __MKSMALLINT(errno);
- __INST(position) = nil;
- } else {
+ if (f == NULL) {
+ /*
+ * If no filedescriptors available, try to finalize
+ * possibly collected fd's and try again.
+ */
+ if (pass == 0 && (errno == ENFILE || errno == EMFILE)) {
+ pass = 1;
+ __SSEND0(@global(ObjectMemory), @symbol(scavenge), 0);
+ __SSEND0(@global(ObjectMemory), @symbol(finalize), 0);
+ goto retry;
+ }
+ getOutOfHere: ;
+ __INST(lastErrorNumber) = __MKSMALLINT(errno);
+ __INST(position) = nil;
+ } else {
#ifdef __VMS__
- /*
- * check to see if this is positionable ...
- */
- __INST(canPosition) = false;
+ /*
+ * check to see if this is positionable ...
+ */
+ __INST(canPosition) = false;
# ifndef _POSIX_C_SOURCE
- {
- struct stat statBuffer;
+ {
+ struct stat statBuffer;
- if (fstat(fileno(f), &statBuffer) >= 0) {
- switch (statBuffer.st_fab_rfm) {
+ if (fstat(fileno(f), &statBuffer) >= 0) {
+ switch (statBuffer.st_fab_rfm) {
case FAB$C_UDF: /* undefined (also stream binary) */
case FAB$C_VAR: /* variable length records */
case FAB$C_VFC: /* variable fixed control */
case FAB$C_STM: /* RMS-11 stream (valid only for sequen> */
default:
- __INST(canPosition) = false;
- break;
+ __INST(canPosition) = false;
+ break;
case FAB$C_FIX: /* fixed length records */
case FAB$C_STMLF: /* LF stream (valid only for sequential> */
case FAB$C_STMCR: /* CR stream (valid only for sequential> */
- __INST(canPosition) = true;
+ __INST(canPosition) = true;
break;
- }
- }
- }
+ }
+ }
+ }
# endif
#else /* not VMS */
- __INST(canPosition) = true;
+ __INST(canPosition) = true;
#endif /* poor VMS */
- __INST(filePointer) = fp = __MKOBJ((INT)f); __STORE(self, fp);
- __INST(position) = __MKSMALLINT(1);
- ok = true;
- }
+ __INST(filePointer) = fp = __MKOBJ((INT)f); __STORE(self, fp);
+ __INST(position) = __MKSMALLINT(1);
+ ok = true;
+ }
}
%}.
ok ifFalse:[
- "
- the open failed for some reason ...
- "
- ^ self openError
+ "
+ the open failed for some reason ...
+ "
+ ^ self openError
].
buffered := true. "default is buffered"
Lobby register:self.
@@ -1074,6 +1074,6 @@
!FileStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/FileStr.st,v 1.65 1999-07-15 19:45:33 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/FileStr.st,v 1.66 1999-08-04 14:13:06 cg Exp $'
! !
FileStream initialize!
--- a/FileStream.st Wed Aug 04 16:12:09 1999 +0200
+++ b/FileStream.st Wed Aug 04 16:13:11 1999 +0200
@@ -738,7 +738,7 @@
|ok|
- filePointer notNil ifTrue:[^ self errorOpen].
+ filePointer notNil ifTrue:[^ self errorAlreadyOpen].
ok := false.
%{
FILE *f;
@@ -750,205 +750,205 @@
path = __INST(pathName);
if (__isNonNilObject(path) && (__qClass(path)==String)) {
#ifdef __VMS__
- do {
- /*
- * allow passing additional RMS arguments.
- * stupid: DEC does not seem to offer an interface for passing a char **.
- */
- errno = 0;
+ do {
+ /*
+ * allow passing additional RMS arguments.
+ * stupid: DEC does not seem to offer an interface for passing a char **.
+ */
+ errno = 0;
- {
- if (__isArray(attributeSpec)) {
- OBJ *ap = __ArrayInstPtr(attributeSpec)->a_element;
- int numAttrib = 0;
- int i;
+ {
+ if (__isArray(attributeSpec)) {
+ OBJ *ap = __ArrayInstPtr(attributeSpec)->a_element;
+ int numAttrib = 0;
+ int i;
- numAttrib = __arraySize(attributeSpec);
- for (i=0; i<numAttrib;i++) {
- if (! __isString(ap[i])) {
- f = NULL;
- errno = EINVAL; /* invalid argument */
- goto getOutOfHere;
- }
- }
- switch (numAttrib) {
- case 0:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode));
- __END_INTERRUPTABLE__
- break;
- case 1:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]));
- __END_INTERRUPTABLE__
- break;
- case 2:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]));
- __END_INTERRUPTABLE__
- break;
- case 3:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]));
- __END_INTERRUPTABLE__
- break;
- case 4:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]));
- __END_INTERRUPTABLE__
- break;
- case 5:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]));
- __END_INTERRUPTABLE__
- break;
- case 6:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]));
- __END_INTERRUPTABLE__
- break;
- case 7:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]));
- __END_INTERRUPTABLE__
- break;
- case 8:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]), __stringVal(ap[7]));
- __END_INTERRUPTABLE__
- break;
- case 9:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]));
- __END_INTERRUPTABLE__
- break;
- case 10:
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
- __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
- __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
- __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]),
- __stringVal(ap[9]));
- __END_INTERRUPTABLE__
- break;
- default:
- f = NULL;
- errno = E2BIG; /* too many args */
- goto getOutOfHere;
- }
- } else if (attributeSpec != nil) {
- f = NULL;
- errno = EINVAL; /* invalid argument */
- goto getOutOfHere;
- } else {
- /*
- * create file as sequential streamLF by default.
- */
- __BEGIN_INTERRUPTABLE__
- f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode), "rfm=stmlf");
- __END_INTERRUPTABLE__
- }
- }
- /* must refetch - could be GC'd */
- path = __INST(pathName);
- } while ((f == NULL) && (errno == EINTR));
+ numAttrib = __arraySize(attributeSpec);
+ for (i=0; i<numAttrib;i++) {
+ if (! __isString(ap[i])) {
+ f = NULL;
+ errno = EINVAL; /* invalid argument */
+ goto getOutOfHere;
+ }
+ }
+ switch (numAttrib) {
+ case 0:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode));
+ __END_INTERRUPTABLE__
+ break;
+ case 1:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]));
+ __END_INTERRUPTABLE__
+ break;
+ case 2:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]));
+ __END_INTERRUPTABLE__
+ break;
+ case 3:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]));
+ __END_INTERRUPTABLE__
+ break;
+ case 4:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]));
+ __END_INTERRUPTABLE__
+ break;
+ case 5:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]));
+ __END_INTERRUPTABLE__
+ break;
+ case 6:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]));
+ __END_INTERRUPTABLE__
+ break;
+ case 7:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]));
+ __END_INTERRUPTABLE__
+ break;
+ case 8:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]), __stringVal(ap[7]));
+ __END_INTERRUPTABLE__
+ break;
+ case 9:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]));
+ __END_INTERRUPTABLE__
+ break;
+ case 10:
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode),
+ __stringVal(ap[0]), __stringVal(ap[1]), __stringVal(ap[2]),
+ __stringVal(ap[3]), __stringVal(ap[4]), __stringVal(ap[5]),
+ __stringVal(ap[6]), __stringVal(ap[7]), __stringVal(ap[8]),
+ __stringVal(ap[9]));
+ __END_INTERRUPTABLE__
+ break;
+ default:
+ f = NULL;
+ errno = E2BIG; /* too many args */
+ goto getOutOfHere;
+ }
+ } else if (attributeSpec != nil) {
+ f = NULL;
+ errno = EINVAL; /* invalid argument */
+ goto getOutOfHere;
+ } else {
+ /*
+ * create file as sequential streamLF by default.
+ */
+ __BEGIN_INTERRUPTABLE__
+ f = fopen((char *)__stringVal(path), (char *)__stringVal(openmode), "rfm=stmlf");
+ __END_INTERRUPTABLE__
+ }
+ }
+ /* must refetch - could be GC'd */
+ path = __INST(pathName);
+ } while ((f == NULL) && (errno == EINTR));
#else
- do {
- __BEGIN_INTERRUPTABLE__
+ do {
+ __BEGIN_INTERRUPTABLE__
# ifdef LINUX
- /*
- * LINUX may ret a non-NULL f even when interrupted.
- * Therefore, check errno and fake a null-ret.
- */
- errno = 0;
- f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
- if (errno == EINTR)
- f = NULL;
+ /*
+ * LINUX may ret a non-NULL f even when interrupted.
+ * Therefore, check errno and fake a null-ret.
+ */
+ errno = 0;
+ f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
+ if (errno == EINTR)
+ f = NULL;
# else
- f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
+ f = fopen((char *) __stringVal(path), (char *) __stringVal(openmode));
# endif
- __END_INTERRUPTABLE__
- /* must refetch - could be GC'd */
- path = __INST(pathName);
- } while ((f == NULL) && (errno == EINTR));
+ __END_INTERRUPTABLE__
+ /* must refetch - could be GC'd */
+ path = __INST(pathName);
+ } while ((f == NULL) && (errno == EINTR));
#endif
- if (f == NULL) {
- /*
- * If no filedescriptors available, try to finalize
- * possibly collected fd's and try again.
- */
- if (pass == 0 && (errno == ENFILE || errno == EMFILE)) {
- pass = 1;
- __SSEND0(@global(ObjectMemory), @symbol(scavenge), 0);
- __SSEND0(@global(ObjectMemory), @symbol(finalize), 0);
- goto retry;
- }
- getOutOfHere: ;
- __INST(lastErrorNumber) = __MKSMALLINT(errno);
- __INST(position) = nil;
- } else {
+ if (f == NULL) {
+ /*
+ * If no filedescriptors available, try to finalize
+ * possibly collected fd's and try again.
+ */
+ if (pass == 0 && (errno == ENFILE || errno == EMFILE)) {
+ pass = 1;
+ __SSEND0(@global(ObjectMemory), @symbol(scavenge), 0);
+ __SSEND0(@global(ObjectMemory), @symbol(finalize), 0);
+ goto retry;
+ }
+ getOutOfHere: ;
+ __INST(lastErrorNumber) = __MKSMALLINT(errno);
+ __INST(position) = nil;
+ } else {
#ifdef __VMS__
- /*
- * check to see if this is positionable ...
- */
- __INST(canPosition) = false;
+ /*
+ * check to see if this is positionable ...
+ */
+ __INST(canPosition) = false;
# ifndef _POSIX_C_SOURCE
- {
- struct stat statBuffer;
+ {
+ struct stat statBuffer;
- if (fstat(fileno(f), &statBuffer) >= 0) {
- switch (statBuffer.st_fab_rfm) {
+ if (fstat(fileno(f), &statBuffer) >= 0) {
+ switch (statBuffer.st_fab_rfm) {
case FAB$C_UDF: /* undefined (also stream binary) */
case FAB$C_VAR: /* variable length records */
case FAB$C_VFC: /* variable fixed control */
case FAB$C_STM: /* RMS-11 stream (valid only for sequen> */
default:
- __INST(canPosition) = false;
- break;
+ __INST(canPosition) = false;
+ break;
case FAB$C_FIX: /* fixed length records */
case FAB$C_STMLF: /* LF stream (valid only for sequential> */
case FAB$C_STMCR: /* CR stream (valid only for sequential> */
- __INST(canPosition) = true;
+ __INST(canPosition) = true;
break;
- }
- }
- }
+ }
+ }
+ }
# endif
#else /* not VMS */
- __INST(canPosition) = true;
+ __INST(canPosition) = true;
#endif /* poor VMS */
- __INST(filePointer) = fp = __MKOBJ((INT)f); __STORE(self, fp);
- __INST(position) = __MKSMALLINT(1);
- ok = true;
- }
+ __INST(filePointer) = fp = __MKOBJ((INT)f); __STORE(self, fp);
+ __INST(position) = __MKSMALLINT(1);
+ ok = true;
+ }
}
%}.
ok ifFalse:[
- "
- the open failed for some reason ...
- "
- ^ self openError
+ "
+ the open failed for some reason ...
+ "
+ ^ self openError
].
buffered := true. "default is buffered"
Lobby register:self.
@@ -1074,6 +1074,6 @@
!FileStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.65 1999-07-15 19:45:33 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/FileStream.st,v 1.66 1999-08-04 14:13:06 cg Exp $'
! !
FileStream initialize!
--- a/PipeStr.st Wed Aug 04 16:12:09 1999 +0200
+++ b/PipeStr.st Wed Aug 04 16:13:11 1999 +0200
@@ -315,18 +315,6 @@
"
!
-writingTo:commandString inDirectory:aDirectory
- "create and return a new pipeStream which can write to the unix command
- given by command. The command is executed in the given directory."
-
- ^ self
- writingTo:commandString errorDisposition:#stderr inDirectory:aDirectory
-
- "unix:
- PipeStream writingTo:'sort'
- "
-!
-
writingTo:commandString errorDisposition:errorDisposition inDirectory:aDirectory
"similar to #writingTo, but changes the directory while
executing the command. Use this if a command is to be
@@ -343,6 +331,18 @@
withMode:'w'
errorDisposition:errorDisposition
inDirectory:aDirectory
+!
+
+writingTo:commandString inDirectory:aDirectory
+ "create and return a new pipeStream which can write to the unix command
+ given by command. The command is executed in the given directory."
+
+ ^ self
+ writingTo:commandString errorDisposition:#stderr inDirectory:aDirectory
+
+ "unix:
+ PipeStream writingTo:'sort'
+ "
! !
!PipeStream class methodsFor:'Signal constants'!
@@ -509,15 +509,15 @@
realCmd execDirectory tmpComFile nullOutput|
filePointer notNil ifTrue:[
- "the pipe was already open ...
- this should (can) not happen."
- ^ self errorOpen
+ "the pipe was already open ...
+ this should (can) not happen."
+ ^ self errorAlreadyOpen
].
rwMode = 'r' ifTrue:[
- mode := #readonly. didWrite := false.
+ mode := #readonly. didWrite := false.
] ifFalse:[
- mode := #writeonly. didWrite := true.
+ mode := #writeonly. didWrite := true.
].
lastErrorNumber := nil.
@@ -528,76 +528,76 @@
execDirectory := aDirectory.
OperatingSystem isVMSlike ifTrue:[
- "/ the generated COM-file includes a 'set default'
- tmpComFile := OperatingSystem createCOMFileForVMSCommand:aCommandString in:aDirectory.
- realCmd := '@' , tmpComFile osName.
- execDirectory := nil.
+ "/ the generated COM-file includes a 'set default'
+ tmpComFile := OperatingSystem createCOMFileForVMSCommand:aCommandString in:aDirectory.
+ realCmd := '@' , tmpComFile osName.
+ execDirectory := nil.
- mbx := OperatingSystem createMailBox.
- mbx isNil ifTrue:[
- lastErrorNumber := OperatingSystem currentErrorNumber.
- tmpComFile delete.
- ^ self openError
- ].
- mbxName := OperatingSystem mailBoxNameOf:mbx.
- "/ 'mailBox is ' print. mbx print. ' name is ' print. mbxName printCR.
- shellPath := ''.
- shellArgs := realCmd.
+ mbx := OperatingSystem createMailBox.
+ mbx isNil ifTrue:[
+ lastErrorNumber := OperatingSystem currentErrorNumber.
+ tmpComFile delete.
+ ^ self openError
+ ].
+ mbxName := OperatingSystem mailBoxNameOf:mbx.
+ "/ 'mailBox is ' print. mbx print. ' name is ' print. mbxName printCR.
+ shellPath := ''.
+ shellArgs := realCmd.
- rwMode = 'r' ifTrue:[
- execFdArray := Array with:0 with:mbx with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:mbx
- ]
- ] ifFalse:[
- execFdArray := Array with:mbx with:1 with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:1
- ]
- ].
- closeFdArray := nil.
+ rwMode = 'r' ifTrue:[
+ execFdArray := Array with:0 with:mbx with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:mbx
+ ]
+ ] ifFalse:[
+ execFdArray := Array with:mbx with:1 with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:1
+ ]
+ ].
+ closeFdArray := nil.
] ifFalse:[
- OperatingSystem isUNIXlike ifTrue:[
- aDirectory notNil ifTrue:[
- "/ unix - prepend a 'cd' to the command
- realCmd := 'cd ' , aDirectory asFilename name, '; ' , aCommandString.
- ] ifFalse:[
- realCmd := aCommandString
- ].
- execDirectory := nil.
- ].
+ OperatingSystem isUNIXlike ifTrue:[
+ aDirectory notNil ifTrue:[
+ "/ unix - prepend a 'cd' to the command
+ realCmd := 'cd ' , aDirectory asFilename name, '; ' , aCommandString.
+ ] ifFalse:[
+ realCmd := aCommandString
+ ].
+ execDirectory := nil.
+ ].
- pipeFdArray := OperatingSystem makePipe.
- pipeFdArray isNil ifTrue:[
- lastErrorNumber := OperatingSystem currentErrorNumber.
- ^ self openError
- ].
+ pipeFdArray := OperatingSystem makePipe.
+ pipeFdArray isNil ifTrue:[
+ lastErrorNumber := OperatingSystem currentErrorNumber.
+ ^ self openError
+ ].
- shellAndArgs := OperatingSystem commandAndArgsForOSCommand:realCmd.
- shellPath := shellAndArgs at:1.
- shellArgs := shellAndArgs at:2.
+ shellAndArgs := OperatingSystem commandAndArgsForOSCommand:realCmd.
+ shellPath := shellAndArgs at:1.
+ shellArgs := shellAndArgs at:2.
- rwMode = 'r' ifTrue:[
- myFd := pipeFdArray at:1.
- execFd := pipeFdArray at:2.
- execFdArray := Array with:0 with:execFd with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:execFd
- ]
- ] ifFalse:[
- myFd := pipeFdArray at:2.
- execFd := pipeFdArray at:1.
- execFdArray := Array with:execFd with:1 with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:1
- ]
- ].
- closeFdArray := Array with:myFd.
+ rwMode = 'r' ifTrue:[
+ myFd := pipeFdArray at:1.
+ execFd := pipeFdArray at:2.
+ execFdArray := Array with:0 with:execFd with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:execFd
+ ]
+ ] ifFalse:[
+ myFd := pipeFdArray at:2.
+ execFd := pipeFdArray at:1.
+ execFdArray := Array with:execFd with:1 with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:1
+ ]
+ ].
+ closeFdArray := Array with:myFd.
].
err == #discard ifTrue:[
- nullOutput := Filename nullDevice writeStream.
- execFdArray at:3 put:nullOutput fileDescriptor
+ nullOutput := Filename nullDevice writeStream.
+ execFdArray at:3 put:nullOutput fileDescriptor
].
"/ must block here, to avoid races due to early finishing
@@ -606,69 +606,69 @@
blocked := OperatingSystem blockInterrupts.
pid := Processor
- monitor:[
- OperatingSystem
- exec:shellPath
- withArguments:shellArgs
- fileDescriptors:execFdArray
- closeDescriptors:closeFdArray
- fork:true
- newPgrp:true
- inDirectory:execDirectory.
- ]
- action:[:status |
- status stillAlive ifFalse:[
- exitStatus := status.
- OperatingSystem closePid:pid.
- pid := nil.
- exitSema signal.
- ].
- ].
+ monitor:[
+ OperatingSystem
+ exec:shellPath
+ withArguments:shellArgs
+ fileDescriptors:execFdArray
+ closeDescriptors:closeFdArray
+ fork:true
+ newPgrp:true
+ inDirectory:execDirectory.
+ ]
+ action:[:status |
+ status stillAlive ifFalse:[
+ exitStatus := status.
+ OperatingSystem closePid:pid.
+ pid := nil.
+ exitSema signal.
+ ].
+ ].
OperatingSystem isVMSlike ifFalse:[
- OperatingSystem closeFd:execFd.
+ OperatingSystem closeFd:execFd.
].
nullOutput notNil ifTrue:[
- nullOutput closeFile
+ nullOutput closeFile
].
pid notNil ifTrue:[
- OperatingSystem isVMSlike ifTrue:[
- "/
- "/ reopen the mailbox as a file ...
- "/
- mbxName := OperatingSystem mailBoxNameOf:mbx.
- mbxName notNil ifTrue:[
- super open:mbxName withMode:rwMode.
- exitAction := [tmpComFile delete].
- ].
- ] ifFalse:[
- self setFileDescriptor:myFd mode:rwMode.
- ]
+ OperatingSystem isVMSlike ifTrue:[
+ "/
+ "/ reopen the mailbox as a file ...
+ "/
+ mbxName := OperatingSystem mailBoxNameOf:mbx.
+ mbxName notNil ifTrue:[
+ super open:mbxName withMode:rwMode.
+ exitAction := [tmpComFile delete].
+ ].
+ ] ifFalse:[
+ self setFileDescriptor:myFd mode:rwMode.
+ ]
] ifFalse:[
- lastErrorNumber := OperatingSystem currentErrorNumber.
- OperatingSystem isVMSlike ifTrue:[
- OperatingSystem destroyMailBox:mbx.
- tmpComFile delete.
- ] ifFalse:[
- OperatingSystem closeFd:myFd.
- ].
+ lastErrorNumber := OperatingSystem currentErrorNumber.
+ OperatingSystem isVMSlike ifTrue:[
+ OperatingSystem destroyMailBox:mbx.
+ tmpComFile delete.
+ ] ifFalse:[
+ OperatingSystem closeFd:myFd.
+ ].
].
blocked ifFalse:[
- OperatingSystem unblockInterrupts
+ OperatingSystem unblockInterrupts
].
lastErrorNumber notNil ifTrue:[
- "
- the pipe open failed for some reason ...
- ... this may be either due to an invalid command string,
- or due to the system running out of memory (when forking
- the unix process)
- "
- exitAction value.
- ^ self openError
+ "
+ the pipe open failed for some reason ...
+ ... this may be either due to an invalid command string,
+ or due to the system running out of memory (when forking
+ the unix process)
+ "
+ exitAction value.
+ ^ self openError
].
commandString := realCmd.
@@ -693,6 +693,6 @@
!PipeStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/PipeStr.st,v 1.78 1999-05-19 12:15:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/PipeStr.st,v 1.79 1999-08-04 14:13:01 cg Exp $'
! !
PipeStream initialize!
--- a/PipeStream.st Wed Aug 04 16:12:09 1999 +0200
+++ b/PipeStream.st Wed Aug 04 16:13:11 1999 +0200
@@ -315,18 +315,6 @@
"
!
-writingTo:commandString inDirectory:aDirectory
- "create and return a new pipeStream which can write to the unix command
- given by command. The command is executed in the given directory."
-
- ^ self
- writingTo:commandString errorDisposition:#stderr inDirectory:aDirectory
-
- "unix:
- PipeStream writingTo:'sort'
- "
-!
-
writingTo:commandString errorDisposition:errorDisposition inDirectory:aDirectory
"similar to #writingTo, but changes the directory while
executing the command. Use this if a command is to be
@@ -343,6 +331,18 @@
withMode:'w'
errorDisposition:errorDisposition
inDirectory:aDirectory
+!
+
+writingTo:commandString inDirectory:aDirectory
+ "create and return a new pipeStream which can write to the unix command
+ given by command. The command is executed in the given directory."
+
+ ^ self
+ writingTo:commandString errorDisposition:#stderr inDirectory:aDirectory
+
+ "unix:
+ PipeStream writingTo:'sort'
+ "
! !
!PipeStream class methodsFor:'Signal constants'!
@@ -509,15 +509,15 @@
realCmd execDirectory tmpComFile nullOutput|
filePointer notNil ifTrue:[
- "the pipe was already open ...
- this should (can) not happen."
- ^ self errorOpen
+ "the pipe was already open ...
+ this should (can) not happen."
+ ^ self errorAlreadyOpen
].
rwMode = 'r' ifTrue:[
- mode := #readonly. didWrite := false.
+ mode := #readonly. didWrite := false.
] ifFalse:[
- mode := #writeonly. didWrite := true.
+ mode := #writeonly. didWrite := true.
].
lastErrorNumber := nil.
@@ -528,76 +528,76 @@
execDirectory := aDirectory.
OperatingSystem isVMSlike ifTrue:[
- "/ the generated COM-file includes a 'set default'
- tmpComFile := OperatingSystem createCOMFileForVMSCommand:aCommandString in:aDirectory.
- realCmd := '@' , tmpComFile osName.
- execDirectory := nil.
+ "/ the generated COM-file includes a 'set default'
+ tmpComFile := OperatingSystem createCOMFileForVMSCommand:aCommandString in:aDirectory.
+ realCmd := '@' , tmpComFile osName.
+ execDirectory := nil.
- mbx := OperatingSystem createMailBox.
- mbx isNil ifTrue:[
- lastErrorNumber := OperatingSystem currentErrorNumber.
- tmpComFile delete.
- ^ self openError
- ].
- mbxName := OperatingSystem mailBoxNameOf:mbx.
- "/ 'mailBox is ' print. mbx print. ' name is ' print. mbxName printCR.
- shellPath := ''.
- shellArgs := realCmd.
+ mbx := OperatingSystem createMailBox.
+ mbx isNil ifTrue:[
+ lastErrorNumber := OperatingSystem currentErrorNumber.
+ tmpComFile delete.
+ ^ self openError
+ ].
+ mbxName := OperatingSystem mailBoxNameOf:mbx.
+ "/ 'mailBox is ' print. mbx print. ' name is ' print. mbxName printCR.
+ shellPath := ''.
+ shellArgs := realCmd.
- rwMode = 'r' ifTrue:[
- execFdArray := Array with:0 with:mbx with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:mbx
- ]
- ] ifFalse:[
- execFdArray := Array with:mbx with:1 with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:1
- ]
- ].
- closeFdArray := nil.
+ rwMode = 'r' ifTrue:[
+ execFdArray := Array with:0 with:mbx with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:mbx
+ ]
+ ] ifFalse:[
+ execFdArray := Array with:mbx with:1 with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:1
+ ]
+ ].
+ closeFdArray := nil.
] ifFalse:[
- OperatingSystem isUNIXlike ifTrue:[
- aDirectory notNil ifTrue:[
- "/ unix - prepend a 'cd' to the command
- realCmd := 'cd ' , aDirectory asFilename name, '; ' , aCommandString.
- ] ifFalse:[
- realCmd := aCommandString
- ].
- execDirectory := nil.
- ].
+ OperatingSystem isUNIXlike ifTrue:[
+ aDirectory notNil ifTrue:[
+ "/ unix - prepend a 'cd' to the command
+ realCmd := 'cd ' , aDirectory asFilename name, '; ' , aCommandString.
+ ] ifFalse:[
+ realCmd := aCommandString
+ ].
+ execDirectory := nil.
+ ].
- pipeFdArray := OperatingSystem makePipe.
- pipeFdArray isNil ifTrue:[
- lastErrorNumber := OperatingSystem currentErrorNumber.
- ^ self openError
- ].
+ pipeFdArray := OperatingSystem makePipe.
+ pipeFdArray isNil ifTrue:[
+ lastErrorNumber := OperatingSystem currentErrorNumber.
+ ^ self openError
+ ].
- shellAndArgs := OperatingSystem commandAndArgsForOSCommand:realCmd.
- shellPath := shellAndArgs at:1.
- shellArgs := shellAndArgs at:2.
+ shellAndArgs := OperatingSystem commandAndArgsForOSCommand:realCmd.
+ shellPath := shellAndArgs at:1.
+ shellArgs := shellAndArgs at:2.
- rwMode = 'r' ifTrue:[
- myFd := pipeFdArray at:1.
- execFd := pipeFdArray at:2.
- execFdArray := Array with:0 with:execFd with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:execFd
- ]
- ] ifFalse:[
- myFd := pipeFdArray at:2.
- execFd := pipeFdArray at:1.
- execFdArray := Array with:execFd with:1 with:2.
- (err == #inline or:[err == #stdout]) ifTrue:[
- execFdArray at:3 put:1
- ]
- ].
- closeFdArray := Array with:myFd.
+ rwMode = 'r' ifTrue:[
+ myFd := pipeFdArray at:1.
+ execFd := pipeFdArray at:2.
+ execFdArray := Array with:0 with:execFd with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:execFd
+ ]
+ ] ifFalse:[
+ myFd := pipeFdArray at:2.
+ execFd := pipeFdArray at:1.
+ execFdArray := Array with:execFd with:1 with:2.
+ (err == #inline or:[err == #stdout]) ifTrue:[
+ execFdArray at:3 put:1
+ ]
+ ].
+ closeFdArray := Array with:myFd.
].
err == #discard ifTrue:[
- nullOutput := Filename nullDevice writeStream.
- execFdArray at:3 put:nullOutput fileDescriptor
+ nullOutput := Filename nullDevice writeStream.
+ execFdArray at:3 put:nullOutput fileDescriptor
].
"/ must block here, to avoid races due to early finishing
@@ -606,69 +606,69 @@
blocked := OperatingSystem blockInterrupts.
pid := Processor
- monitor:[
- OperatingSystem
- exec:shellPath
- withArguments:shellArgs
- fileDescriptors:execFdArray
- closeDescriptors:closeFdArray
- fork:true
- newPgrp:true
- inDirectory:execDirectory.
- ]
- action:[:status |
- status stillAlive ifFalse:[
- exitStatus := status.
- OperatingSystem closePid:pid.
- pid := nil.
- exitSema signal.
- ].
- ].
+ monitor:[
+ OperatingSystem
+ exec:shellPath
+ withArguments:shellArgs
+ fileDescriptors:execFdArray
+ closeDescriptors:closeFdArray
+ fork:true
+ newPgrp:true
+ inDirectory:execDirectory.
+ ]
+ action:[:status |
+ status stillAlive ifFalse:[
+ exitStatus := status.
+ OperatingSystem closePid:pid.
+ pid := nil.
+ exitSema signal.
+ ].
+ ].
OperatingSystem isVMSlike ifFalse:[
- OperatingSystem closeFd:execFd.
+ OperatingSystem closeFd:execFd.
].
nullOutput notNil ifTrue:[
- nullOutput closeFile
+ nullOutput closeFile
].
pid notNil ifTrue:[
- OperatingSystem isVMSlike ifTrue:[
- "/
- "/ reopen the mailbox as a file ...
- "/
- mbxName := OperatingSystem mailBoxNameOf:mbx.
- mbxName notNil ifTrue:[
- super open:mbxName withMode:rwMode.
- exitAction := [tmpComFile delete].
- ].
- ] ifFalse:[
- self setFileDescriptor:myFd mode:rwMode.
- ]
+ OperatingSystem isVMSlike ifTrue:[
+ "/
+ "/ reopen the mailbox as a file ...
+ "/
+ mbxName := OperatingSystem mailBoxNameOf:mbx.
+ mbxName notNil ifTrue:[
+ super open:mbxName withMode:rwMode.
+ exitAction := [tmpComFile delete].
+ ].
+ ] ifFalse:[
+ self setFileDescriptor:myFd mode:rwMode.
+ ]
] ifFalse:[
- lastErrorNumber := OperatingSystem currentErrorNumber.
- OperatingSystem isVMSlike ifTrue:[
- OperatingSystem destroyMailBox:mbx.
- tmpComFile delete.
- ] ifFalse:[
- OperatingSystem closeFd:myFd.
- ].
+ lastErrorNumber := OperatingSystem currentErrorNumber.
+ OperatingSystem isVMSlike ifTrue:[
+ OperatingSystem destroyMailBox:mbx.
+ tmpComFile delete.
+ ] ifFalse:[
+ OperatingSystem closeFd:myFd.
+ ].
].
blocked ifFalse:[
- OperatingSystem unblockInterrupts
+ OperatingSystem unblockInterrupts
].
lastErrorNumber notNil ifTrue:[
- "
- the pipe open failed for some reason ...
- ... this may be either due to an invalid command string,
- or due to the system running out of memory (when forking
- the unix process)
- "
- exitAction value.
- ^ self openError
+ "
+ the pipe open failed for some reason ...
+ ... this may be either due to an invalid command string,
+ or due to the system running out of memory (when forking
+ the unix process)
+ "
+ exitAction value.
+ ^ self openError
].
commandString := realCmd.
@@ -693,6 +693,6 @@
!PipeStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.78 1999-05-19 12:15:38 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.79 1999-08-04 14:13:01 cg Exp $'
! !
PipeStream initialize!