File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1212# define S_ISDIR (mode ) (((mode) & S_IFMT) == S_IFDIR)
1313#else
1414# include < unistd.h>
15+ # include < fcntl.h>
1516#endif
1617#include < cstdio>
1718#include < vector>
@@ -469,6 +470,20 @@ namespace Sass {
469470 CloseHandle (hFile);
470471 // just convert from unsigned char*
471472 char * contents = (char *) pBuffer;
473+ #elif __APPLE__
474+ // On OSX `fopen` can fail with "too many open files" but succeeds using `open`.
475+ struct stat st;
476+ if (stat (path.c_str (), &st) == -1 || S_ISDIR (st.st_mode )) return 0 ;
477+ int file = open (path.c_str (), O_RDONLY);
478+ char * contents = 0 ;
479+ if (file != -1 ) {
480+ size_t size = st.st_size ;
481+ contents = (char *) malloc ((size+2 )*sizeof (char ));
482+ read (file, contents, size);
483+ contents[size+0 ] = ' \0 ' ;
484+ contents[size+1 ] = ' \0 ' ;
485+ close (file);
486+ }
472487 #else
473488 // Read the file using `<cstdio>` instead of `<fstream>` for better portability.
474489 // The `<fstream>` header initializes `<locale>` and this buggy in GCC4/5 with static linking.
You can’t perform that action at this time.
0 commit comments