-
- int fd, oflag, mode ;
-
- if (_writeable) {
- oflag = O_RDWR | O_CREAT | O_BINARY ;
- mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ;
- } else {
- oflag = O_RDONLY | O_BINARY ;
- mode = 0 ;
- }
-
- if (mode == 0) {
- fd = ::open (_path.c_str(), oflag) ;
- } else {
- fd = ::open (_path.c_str(), oflag, mode) ;
- }
-
- if (fd == -1) return false;
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
-
- _sndfile = sf_open_fd (fd, _writeable ? SFM_RDWR : SFM_READ, _info, 1);
-
- if (_sndfile == 0) {
- ::close(fd);
- }
-