~ppsspp/ppsspp/ffmpeg

« back to all changes in this revision

Viewing changes to libavutil/file_open.c

  • Committer: Henrik Rydgård
  • Date: 2014-01-03 10:44:32 UTC
  • Revision ID: git-v1:87c6c126784b1718bfa448ecf2e6a9fef781eb4e
Update our ffmpeg snapshot to a clone of the official repository.

This is because Maxim's at3plus support has been officially merged!

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
 
86
86
    fd = open(filename, flags, mode);
87
87
#if HAVE_FCNTL
88
 
    if (fd != -1)
89
 
        fcntl(fd, F_SETFD, FD_CLOEXEC);
 
88
    if (fd != -1) {
 
89
        if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
 
90
            av_log(NULL, AV_LOG_DEBUG, "Failed to set close on exec\n");
 
91
    }
90
92
#endif
91
93
 
92
94
    return fd;
93
95
}
 
96
 
 
97
FILE *av_fopen_utf8(const char *path, const char *mode)
 
98
{
 
99
    int fd;
 
100
    int access;
 
101
    const char *m = mode;
 
102
 
 
103
    switch (*m++) {
 
104
    case 'r': access = O_RDONLY; break;
 
105
    case 'w': access = O_CREAT|O_WRONLY|O_TRUNC; break;
 
106
    case 'a': access = O_CREAT|O_WRONLY|O_APPEND; break;
 
107
    default :
 
108
        errno = EINVAL;
 
109
        return NULL;
 
110
    }
 
111
    while (*m) {
 
112
        if (*m == '+') {
 
113
            access &= ~(O_RDONLY | O_WRONLY);
 
114
            access |= O_RDWR;
 
115
        } else if (*m == 'b') {
 
116
#ifdef O_BINARY
 
117
            access |= O_BINARY;
 
118
#endif
 
119
        } else if (*m) {
 
120
            errno = EINVAL;
 
121
            return NULL;
 
122
        }
 
123
        m++;
 
124
    }
 
125
    fd = avpriv_open(path, access, 0666);
 
126
    if (fd == -1)
 
127
        return NULL;
 
128
    return fdopen(fd, mode);
 
129
}