Commit edea4db 1 parent ba6510a commit edea4db Copy full SHA for edea4db
File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 12
12
# define S_ISDIR (mode ) (((mode) & S_IFMT) == S_IFDIR)
13
13
#else
14
14
# include < unistd.h>
15
+ # include < fcntl.h>
15
16
#endif
16
17
#include < cstdio>
17
18
#include < vector>
@@ -469,6 +470,20 @@ namespace Sass {
469
470
CloseHandle (hFile);
470
471
// just convert from unsigned char*
471
472
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
+ }
472
487
#else
473
488
// Read the file using `<cstdio>` instead of `<fstream>` for better portability.
474
489
// 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