static void png_mkdir(char *buf, int verbose) { struct stat stat_p; #ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { #else if ( mkdir(buf) < 0 ) { #endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: if ( stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_UnableToAccess,buf); exit_player(EXIT_ERROR); } if ( !S_ISDIR(stat_p.st_mode) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_ExistsButNoDirectory); exit_player(EXIT_ERROR); } if ( !(stat_p.st_mode & S_IWUSR) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsButNotWritable); exit_player(EXIT_ERROR); } mp_msg(MSGT_VO, MSGL_INFO, "%s: %s: %s\n", info.short_name, MSGTR_VO_OutputDirectory, buf); break; default: mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_CantCreateDirectory); exit_player(EXIT_ERROR); } /* end switch */ } else if ( verbose ) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirectoryCreateSuccess); } /* end if */ } static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { char buf[BUFLENGTH]; if(z_compression == 0) { mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); } snprintf(buf, BUFLENGTH, "%s", png_outdir); png_mkdir(buf, 1); mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); if (avctx && png_format != format) { avcodec_close(avctx); av_freep(&avctx); } if (!avctx) { avctx = avcodec_alloc_context3(NULL); avctx->compression_level = z_compression; avctx->pix_fmt = imgfmt2pixfmt(format); avctx->width = width; avctx->height = height; if (avcodec_open2(avctx, avcodec_find_encoder(AV_CODEC_ID_PNG), NULL) < 0) { uninit(); return -1; } png_format = format; } return 0; }
static void png_mkdir(char *buf, int verbose) { struct stat stat_p; #ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { #else if ( mkdir(buf) < 0 ) { #endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: if ( stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_UnableToAccess,buf); exit_player(EXIT_ERROR); } if ( !S_ISDIR(stat_p.st_mode) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_ExistsButNoDirectory); exit_player(EXIT_ERROR); } if ( !(stat_p.st_mode & S_IWUSR) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsButNotWritable); exit_player(EXIT_ERROR); } mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsAndIsWritable); break; default: mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_CantCreateDirectory); exit_player(EXIT_ERROR); } /* end switch */ } else if ( verbose ) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirectoryCreateSuccess); } /* end if */ } static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { char buf[BUFLENGTH]; if(z_compression == 0) { mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); } snprintf(buf, BUFLENGTH, "%s", png_outdir); png_mkdir(buf, 1); mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); return 0; }