[FFmpeg-devel] [PATCH] preset dir for win32

Gianluigi Tiesi mplayer at netfarm.it
Sat May 21 02:24:01 CEST 2011


On Wed, May 18, 2011 at 01:24:17PM +0200, Michael Niedermayer wrote:
> is below ok?
> 
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -848,6 +848,19 @@ FILE *get_preset_file(char *filename, size_t filename_size,
>          av_strlcpy(filename, preset_name, filename_size);
>          f = fopen(filename, "r");
>      } else {
> +#ifdef _WIN32
> +        char arr[MAX_PATH], *ls;
> +
> +        if (!GetModuleFileName(GetModuleHandle(NULL), arr, sizeof(arr) - 1))
> +            return NULL;
> +
> +        if (!(ls = strrchr(arr, '\\')))
> +            return NULL;
> +
> +        *ls = 0;
> +
> +        base[2]= arr;
> +#endif
>          for (i = 0; i < 3 && !f; i++) {
>              if (!base[i])
>                  continue;
> 
> 

oh, good idea, I've revised the patch a bit:
- make explicit use of GetModuleFileNameA and GetModuleHandleA
- renamed arr to datadir
- conversion from backslash to forward slash to avoid mixing (it should be ok but I've got some problems)
- added /ffpresets to executable directory, it's better to have ffpresets/abc.preset
- when an error occurs base[2] will be NULL, so at least base[0] and base[1] are checked
- documented doxygen comment cmdutils.h and ffmpeg.texi (please check, I'm Italian :D)

Regards

-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffpresets-datadir-on-win32.diff
Type: text/x-diff
Size: 2235 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110521/9ffe7b4b/attachment.bin>


More information about the ffmpeg-devel mailing list