Browse code

preset dir for win32

Gianluigi Tiesi authored on 2011/05/21 10:36:26
Showing 3 changed files
... ...
@@ -849,6 +849,23 @@ FILE *get_preset_file(char *filename, size_t filename_size,
849 849
         av_strlcpy(filename, preset_name, filename_size);
850 850
         f = fopen(filename, "r");
851 851
     } else {
852
+#ifdef _WIN32
853
+        char datadir[MAX_PATH], *ls;
854
+        base[2] = NULL;
855
+
856
+        if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1))
857
+        {
858
+            for (ls = datadir; ls < datadir + strlen(datadir); ls++)
859
+                if (*ls == '\\') *ls = '/';
860
+
861
+            if (ls = strrchr(datadir, '/'))
862
+            {
863
+                *ls = 0;
864
+                strncat(datadir, "/ffpresets",  sizeof(datadir) - 1 - strlen(datadir));
865
+                base[2] = datadir;
866
+            }
867
+        }
868
+#endif
852 869
         for (i = 0; i < 3 && !f; i++) {
853 870
             if (!base[i])
854 871
                 continue;
... ...
@@ -243,7 +243,8 @@ int read_file(const char *filename, char **bufptr, size_t *size);
243 243
  * If is_path is non-zero, look for the file in the path preset_name.
244 244
  * Otherwise search for a file named arg.ffpreset in the directories
245 245
  * $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined
246
- * at configuration time, in that order. If no such file is found and
246
+ * at configuration time or in a "ffpresets" folder along the executable
247
+ * on win32, in that order. If no such file is found and
247 248
  * codec_name is defined, then search for a file named
248 249
  * codec_name-preset_name.ffpreset in the above-mentioned directories.
249 250
  *
... ...
@@ -816,6 +816,7 @@ following rules:
816 816
 First ffmpeg searches for a file named @var{arg}.ffpreset in the
817 817
 directories @file{$FFMPEG_DATADIR} (if set), and @file{$HOME/.ffmpeg}, and in
818 818
 the datadir defined at configuration time (usually @file{PREFIX/share/ffmpeg})
819
+or in a @file{ffpresets} folder along the executable on win32,
819 820
 in that order. For example, if the argument is @code{libx264-max}, it will
820 821
 search for the file @file{libx264-max.ffpreset}.
821 822