Index: library.c =================================================================== RCS file: /nfs/ccpdisk/xtal/CVSROOT/ccp4/lib/src/library.c,v retrieving revision 1.62 retrieving revision 1.63 diff -c -r1.62 -r1.63 *** library.c 2002/06/14 12:31:51 1.62 --- library.c 2002/12/03 11:43:32 1.63 *************** *** 15,21 **** /* \newcommand{\idx}[1]{#1\index{#1}} */ /* \newcommand{\fixme}[1]{\index{Fixme!}[{\bf Fixme!:} #1\@.]} */ /* */ ! /* \title{C library routines}\date{$ $Date: 2002/06/14 12:31:51 $ $} */ /* \author{This version: Dave Love, Daresbury} */ /* */ /* \makeindex */ --- 15,21 ---- /* \newcommand{\idx}[1]{#1\index{#1}} */ /* \newcommand{\fixme}[1]{\index{Fixme!}[{\bf Fixme!:} #1\@.]} */ /* */ ! /* \title{C library routines}\date{$ $Date: 2002/12/03 11:43:32 $ $} */ /* \author{This version: Dave Love, Daresbury} */ /* */ /* \makeindex */ *************** *** 98,104 **** /* Include library.h */ #include "library.h" /* = */ ! static char rcsid[] = "$Id: library.c,v 1.62 2002/06/14 12:31:51 ccb Exp $"; static int initialised = 0; /* flag to initialise data and file streams */ /* These DISKIO file modes used to include a [[b]] since they're */ /* binary. This caused serious lossage when reading a (scratch) file */ --- 98,104 ---- /* Include library.h */ #include "library.h" /* = */ ! static char rcsid[] = "$Id: library.c,v 1.63 2002/12/03 11:43:32 ccb Exp $"; static int initialised = 0; /* flag to initialise data and file streams */ /* These DISKIO file modes used to include a [[b]] since they're */ /* binary. This caused serious lossage when reading a (scratch) file */ *************** *** 1447,1460 **** int ccp4_mkdir (const char *path, const char *cmode) #ifndef _MVS { ! mode_t mode; int result; /* Possible modes (see stat.h) Currently pass 3-character string and interpret as octal. Try also S_IRWXU, S_IRWXG, etc. */ sscanf(cmode,"%o",&mode); ! result = mkdir(path,mode); if (result == -1) { --- 1447,1486 ---- int ccp4_mkdir (const char *path, const char *cmode) #ifndef _MVS { ! mode_t mode=0; int result; + #if defined (__APPLE__) + static const unsigned short TBM = 0x07; + switch (strlen(cmode)) { + case 4: + mode |= (*cmode & TBM) << 9 ; + mode |= (*(cmode+1) & TBM) << 6 ; + mode |= (*(cmode+2) & TBM) << 3 ; + mode |= (*(cmode+3) & TBM) ; + break; + case 3: + mode |= (*cmode & TBM) << 6 ; + mode |= (*(cmode+1) & TBM) << 3 ; + mode |= (*(cmode+2) & TBM) ; + break; + case 2: + mode |= (*cmode & TBM) << 3 ; + mode |= (*(cmode+1) & TBM) ; + break; + case 1: + mode |= (*cmode & TBM) ; + break; + default: + mode = 0x0fff ; + } + #else /* Possible modes (see stat.h) Currently pass 3-character string and interpret as octal. Try also S_IRWXU, S_IRWXG, etc. */ sscanf(cmode,"%o",&mode); ! #endif ! result = mkdir(path,mode); if (result == -1) { *************** *** 1474,1486 **** int ccp4_chmod (const char *path, const char *cmode) #ifndef _MVS ! { mode_t mode; ! /* Possible modes (see stat.h) Currently pass 3-character string and interpret as octal. Try also S_IRWXU, S_IRWXG, etc. */ sscanf(cmode,"%o",&mode); ! return (chmod(path,mode)); } #else --- 1500,1537 ---- int ccp4_chmod (const char *path, const char *cmode) #ifndef _MVS ! { mode_t mode=0; ! #if defined (__APPLE__) ! static const unsigned short TBM = 0x07; ! ! switch (strlen(cmode)) { ! case 4: ! mode |= (*cmode & TBM) << 9 ; ! mode |= (*(cmode+1) & TBM) << 6 ; ! mode |= (*(cmode+2) & TBM) << 3 ; ! mode |= (*(cmode+3) & TBM) ; ! break; ! case 3: ! mode |= (*cmode & TBM) << 6 ; ! mode |= (*(cmode+1) & TBM) << 3 ; ! mode |= (*(cmode+2) & TBM) ; ! break; ! case 2: ! mode |= (*cmode & TBM) << 3 ; ! mode |= (*(cmode+1) & TBM) ; ! break; ! case 1: ! mode |= (*cmode & TBM) ; ! break; ! default: ! mode = 0x0fff ; ! } ! #else /* Possible modes (see stat.h) Currently pass 3-character string and interpret as octal. Try also S_IRWXU, S_IRWXG, etc. */ sscanf(cmode,"%o",&mode); ! #endif return (chmod(path,mode)); } #else