--- 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!