From 70c66c04764421ca277c341657c556cb0f00ec9b Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 20 Mar 2010 23:38:27 +0000 Subject: Rename get_path.[ch] --> path.[ch]. These files now contain different functions related to path handling. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30943 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 2 +- command.c | 2 +- get_path.c | 195 ------------------------------------------------- get_path.h | 30 -------- gui/cfg.c | 2 +- gui/interface.c | 2 +- gui/win32/dialogs.c | 2 +- gui/win32/interface.c | 2 +- gui/win32/wincfg.c | 2 +- input/input.c | 2 +- libaf/af_export.c | 2 +- libass/ass_mp.c | 2 +- libmpcodecs/vd_xanim.c | 2 +- libvo/font_load_ft.c | 2 +- libvo/vo_dxr2.c | 2 +- loader/drv.c | 2 +- loader/elfdll.c | 2 +- loader/module.c | 2 +- loader/registry.c | 2 +- loader/win32.c | 2 +- mencoder.c | 2 +- mplayer.c | 2 +- path.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++ path.h | 30 ++++++++ stream/stream_dvb.c | 2 +- 25 files changed, 246 insertions(+), 246 deletions(-) delete mode 100644 get_path.c delete mode 100644 get_path.h create mode 100644 path.c create mode 100644 path.h diff --git a/Makefile b/Makefile index b698bf6289..4773345028 100644 --- a/Makefile +++ b/Makefile @@ -344,12 +344,12 @@ SRCS_COMMON = asxparser.c \ edl.c \ find_sub.c \ fmt-conversion.c \ - get_path.c \ m_config.c \ m_option.c \ m_struct.c \ mpcommon.c \ parser-cfg.c \ + path.c \ playtree.c \ playtreeparser.c \ spudec.c \ diff --git a/command.c b/command.c index cd9d2abf5d..a62e0bb77f 100644 --- a/command.c +++ b/command.c @@ -46,7 +46,7 @@ #include "libmpcodecs/dec_teletext.h" #include "vobsub.h" #include "spudec.h" -#include "get_path.h" +#include "path.h" #include "stream/tv.h" #include "stream/stream_radio.h" #include "stream/pvr.h" diff --git a/get_path.c b/get_path.c deleted file mode 100644 index 90d428a4df..0000000000 --- a/get_path.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Get path to config dir/file. - * - * Return Values: - * Returns the pointer to the ALLOCATED buffer containing the - * zero terminated path string. This buffer has to be FREED - * by the caller. - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include "config.h" -#include "mp_msg.h" -#include "get_path.h" - -#ifdef CONFIG_MACOSX_BUNDLE -#include -#include -#include -#include -#elif defined(__MINGW32__) -#include -#elif defined(__CYGWIN__) -#include -#include -#endif - -#include "osdep/osdep.h" - -char *get_path(const char *filename){ - char *homedir; - char *buff; -#ifdef __MINGW32__ - static char *config_dir = "/mplayer"; -#else - static char *config_dir = "/.mplayer"; -#endif - int len; -#ifdef CONFIG_MACOSX_BUNDLE - struct stat dummy; - CFIndex maxlen=256; - CFURLRef res_url_ref=NULL; - CFURLRef bdl_url_ref=NULL; - char *res_url_path = NULL; - char *bdl_url_path = NULL; -#endif - - if ((homedir = getenv("MPLAYER_HOME")) != NULL) - config_dir = ""; - else if ((homedir = getenv("HOME")) == NULL) -#if defined(__MINGW32__) || defined(__CYGWIN__) - /* Hack to get fonts etc. loaded outside of Cygwin environment. */ - { - int i,imax=0; - char exedir[260]; - GetModuleFileNameA(NULL, exedir, 260); - for (i=0; i< strlen(exedir); i++) - if (exedir[i] =='\\') - {exedir[i]='/'; imax=i;} - exedir[imax]='\0'; - homedir = exedir; - } -#elif defined(__OS2__) - { - PPIB ppib; - char path[260]; - - // Get process info blocks - DosGetInfoBlocks(NULL, &ppib); - - // Get full path of the executable - DosQueryModuleName(ppib->pib_hmte, sizeof( path ), path); - - // Truncate name part including last backslash - *strrchr(path, '\\') = 0; - - // Convert backslash to slash - _fnslashify(path); - - homedir = path; - } -#else - return NULL; -#endif - len = strlen(homedir) + strlen(config_dir) + 1; - if (filename == NULL) { - if ((buff = malloc(len)) == NULL) - return NULL; - sprintf(buff, "%s%s", homedir, config_dir); - } else { - len += strlen(filename) + 1; - if ((buff = malloc(len)) == NULL) - return NULL; - sprintf(buff, "%s%s/%s", homedir, config_dir, filename); - } - -#ifdef CONFIG_MACOSX_BUNDLE - if (stat(buff, &dummy)) { - - res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); - bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle()); - - if (res_url_ref&&bdl_url_ref) { - - res_url_path=malloc(maxlen); - bdl_url_path=malloc(maxlen); - - while (!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) { - maxlen*=2; - res_url_path=realloc(res_url_path, maxlen); - } - CFRelease(res_url_ref); - - while (!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) { - maxlen*=2; - bdl_url_path=realloc(bdl_url_path, maxlen); - } - CFRelease(bdl_url_ref); - - if (strcmp(res_url_path, bdl_url_path) == 0) - res_url_path = NULL; - } - - if (res_url_path&&filename) { - if ((strlen(filename)+strlen(res_url_path)+2)>maxlen) { - maxlen=strlen(filename)+strlen(res_url_path)+2; - } - free(buff); - buff = malloc(maxlen); - strcpy(buff, res_url_path); - - strcat(buff,"/"); - strcat(buff, filename); - } - } -#endif - mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); - return buff; -} - -#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) -void set_path_env(void) -{ - /*make our codec dirs available for LoadLibraryA()*/ - char win32path[MAX_PATH]; -#ifdef __CYGWIN__ - cygwin_conv_to_full_win32_path(BINARY_CODECS_PATH, win32path); -#else /*__CYGWIN__*/ - /* Expand to absolute path unless it's already absolute */ - if (!strstr(BINARY_CODECS_PATH,":") && BINARY_CODECS_PATH[0] != '\\') { - GetModuleFileNameA(NULL, win32path, MAX_PATH); - strcpy(strrchr(win32path, '\\') + 1, BINARY_CODECS_PATH); - } - else strcpy(win32path, BINARY_CODECS_PATH); -#endif /*__CYGWIN__*/ - mp_msg(MSGT_WIN32, MSGL_V, "Setting PATH to %s\n", win32path); - if (!SetEnvironmentVariableA("PATH", win32path)) - mp_msg(MSGT_WIN32, MSGL_WARN, "Cannot set PATH!"); -} -#endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ - -char *def_path = BINARY_CODECS_PATH; - -static int needs_free = 0; - -void SetCodecPath(const char *path) -{ - if (needs_free) - free(def_path); - if (path == 0) { - def_path = BINARY_CODECS_PATH; - needs_free = 0; - return; - } - def_path = malloc(strlen(path) + 1); - strcpy(def_path, path); - needs_free = 1; -} diff --git a/get_path.h b/get_path.h deleted file mode 100644 index 6713762937..0000000000 --- a/get_path.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Get path to config dir/file. - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_GET_PATH_H -#define MPLAYER_GET_PATH_H - -extern char *def_path; - -char *get_path(const char *filename); -void set_path_env(void); -void SetCodecPath(const char *path); - -#endif /* MPLAYER_GET_PATH_H */ diff --git a/gui/cfg.c b/gui/cfg.c index 3d564b4200..492a2d191d 100644 --- a/gui/cfg.c +++ b/gui/cfg.c @@ -27,7 +27,7 @@ #include "mplayer.h" #include "m_config.h" #include "m_option.h" -#include "get_path.h" +#include "path.h" #include "libmpcodecs/vd.h" #include "libvo/sub.h" #include "libvo/video_out.h" diff --git a/gui/interface.c b/gui/interface.c index 8040f5c92c..17f6183033 100644 --- a/gui/interface.c +++ b/gui/interface.c @@ -36,7 +36,7 @@ #include "app.h" #include "cfg.h" #include "help_mp.h" -#include "get_path.h" +#include "path.h" #include "mp_core.h" #include "mplayer.h" #include "libmpcodecs/vd.h" diff --git a/gui/win32/dialogs.c b/gui/win32/dialogs.c index edd63d570c..bd0ac56793 100644 --- a/gui/win32/dialogs.c +++ b/gui/win32/dialogs.c @@ -23,7 +23,7 @@ #include #include -#include +#include "path.h" #include "gui/interface.h" #include "mp_msg.h" #include "help_mp.h" diff --git a/gui/win32/interface.c b/gui/win32/interface.c index 5fbaa1ed64..6c4f07200e 100644 --- a/gui/win32/interface.c +++ b/gui/win32/interface.c @@ -22,7 +22,7 @@ */ #include -#include +#include "path.h" #include "gui/interface.h" #include "m_option.h" #include "mixer.h" diff --git a/gui/win32/wincfg.c b/gui/win32/wincfg.c index 33d5ae9fd6..539b7402cf 100644 --- a/gui/win32/wincfg.c +++ b/gui/win32/wincfg.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include "path.h" #include "mplayer.h" #include "mp_msg.h" #include "help_mp.h" diff --git a/input/input.c b/input/input.c index 59afa23501..c0adf35428 100644 --- a/input/input.c +++ b/input/input.c @@ -43,7 +43,7 @@ #include "help_mp.h" #include "m_config.h" #include "m_option.h" -#include "get_path.h" +#include "path.h" #include "joystick.h" diff --git a/libaf/af_export.c b/libaf/af_export.c index 949f3f18ca..e3eb917fc7 100644 --- a/libaf/af_export.c +++ b/libaf/af_export.c @@ -38,7 +38,7 @@ #include #include "af.h" -#include "get_path.h" +#include "path.h" #define DEF_SZ 512 // default buffer size (in samples) #define SHARED_FILE "mplayer-af_export" /* default file name diff --git a/libass/ass_mp.c b/libass/ass_mp.c index 2da7cbca03..4f1ff60204 100644 --- a/libass/ass_mp.c +++ b/libass/ass_mp.c @@ -25,7 +25,7 @@ #include #include "mp_msg.h" -#include "get_path.h" +#include "path.h" #include "ass_mp.h" #include "help_mp.h" diff --git a/libmpcodecs/vd_xanim.c b/libmpcodecs/vd_xanim.c index 66fbb95175..70f9306ba3 100644 --- a/libmpcodecs/vd_xanim.c +++ b/libmpcodecs/vd_xanim.c @@ -29,7 +29,7 @@ #include /* strerror */ #include "config.h" -#include "get_path.h" +#include "path.h" #include "mp_msg.h" #include "vd_internal.h" diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c index 49c1c764c7..87249f5962 100644 --- a/libvo/font_load_ft.c +++ b/libvo/font_load_ft.c @@ -48,7 +48,7 @@ #include "mp_msg.h" #include "help_mp.h" #include "mplayer.h" -#include "get_path.h" +#include "path.h" #include "osd_font.h" #if (FREETYPE_MAJOR > 2) || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 1) diff --git a/libvo/vo_dxr2.c b/libvo/vo_dxr2.c index 0e1ac2fc35..28fd7a86bb 100644 --- a/libvo/vo_dxr2.c +++ b/libvo/vo_dxr2.c @@ -35,7 +35,7 @@ #include "mp_msg.h" #include "m_option.h" #include "sub.h" -#include "get_path.h" +#include "path.h" #include "libmpdemux/mpeg_packetizer.h" #include "x11_common.h" diff --git a/loader/drv.c b/loader/drv.c index ece4aa3456..fbc4007734 100644 --- a/loader/drv.c +++ b/loader/drv.c @@ -25,7 +25,7 @@ #ifndef __MINGW32__ #include "ext.h" #endif -#include "get_path.h" +#include "path.h" #if 1 diff --git a/loader/elfdll.c b/loader/elfdll.c index b0317bf91a..5c33d2bde9 100644 --- a/loader/elfdll.c +++ b/loader/elfdll.c @@ -18,7 +18,7 @@ #include "wine/debugtools.h" #include "wine/winerror.h" #include "debug.h" -#include "get_path.h" +#include "path.h" //DEFAULT_DEBUG_CHANNEL(elfdll) diff --git a/loader/module.c b/loader/module.c index 0d4f8087ce..b6eebcf19d 100644 --- a/loader/module.c +++ b/loader/module.c @@ -46,7 +46,7 @@ #endif #include "win32.h" #include "drv.h" -#include "get_path.h" +#include "path.h" #ifdef EMU_QTX_API #include "wrapper.h" diff --git a/loader/registry.c b/loader/registry.c index 9964eeb9ff..cab63ceb72 100644 --- a/loader/registry.c +++ b/loader/registry.c @@ -21,7 +21,7 @@ #include "ext.h" #include "registry.h" -#include "get_path.h" +#include "path.h" //#undef TRACE //#define TRACE printf diff --git a/loader/win32.c b/loader/win32.c index 52a7b2c6c5..fe8b198944 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -49,7 +49,7 @@ for DLL to know too much about its environment. #include "loader.h" #include "com.h" #include "ext.h" -#include "get_path.h" +#include "path.h" #include #include diff --git a/mencoder.c b/mencoder.c index dcddaa649a..8b8b76c0ba 100644 --- a/mencoder.c +++ b/mencoder.c @@ -63,7 +63,7 @@ #include "parser-mecmd.h" #include "parser-cfg.h" #include "mp_fifo.h" -#include "get_path.h" +#include "path.h" #include "stream/stream.h" #include "libmpdemux/aviprint.h" diff --git a/mplayer.c b/mplayer.c index 3602a04e82..4c4f4d8f2e 100644 --- a/mplayer.c +++ b/mplayer.c @@ -148,7 +148,7 @@ static int cfg_include(m_option_t *conf, char *filename){ return m_config_parse_config_file(mconfig, filename); } -#include "get_path.h" +#include "path.h" //**************************************************************************// //**************************************************************************// diff --git a/path.c b/path.c new file mode 100644 index 0000000000..495f292af9 --- /dev/null +++ b/path.c @@ -0,0 +1,195 @@ +/* + * Get path to config dir/file. + * + * Return Values: + * Returns the pointer to the ALLOCATED buffer containing the + * zero terminated path string. This buffer has to be FREED + * by the caller. + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include "config.h" +#include "mp_msg.h" +#include "path.h" + +#ifdef CONFIG_MACOSX_BUNDLE +#include +#include +#include +#include +#elif defined(__MINGW32__) +#include +#elif defined(__CYGWIN__) +#include +#include +#endif + +#include "osdep/osdep.h" + +char *get_path(const char *filename){ + char *homedir; + char *buff; +#ifdef __MINGW32__ + static char *config_dir = "/mplayer"; +#else + static char *config_dir = "/.mplayer"; +#endif + int len; +#ifdef CONFIG_MACOSX_BUNDLE + struct stat dummy; + CFIndex maxlen=256; + CFURLRef res_url_ref=NULL; + CFURLRef bdl_url_ref=NULL; + char *res_url_path = NULL; + char *bdl_url_path = NULL; +#endif + + if ((homedir = getenv("MPLAYER_HOME")) != NULL) + config_dir = ""; + else if ((homedir = getenv("HOME")) == NULL) +#if defined(__MINGW32__) || defined(__CYGWIN__) + /* Hack to get fonts etc. loaded outside of Cygwin environment. */ + { + int i,imax=0; + char exedir[260]; + GetModuleFileNameA(NULL, exedir, 260); + for (i=0; i< strlen(exedir); i++) + if (exedir[i] =='\\') + {exedir[i]='/'; imax=i;} + exedir[imax]='\0'; + homedir = exedir; + } +#elif defined(__OS2__) + { + PPIB ppib; + char path[260]; + + // Get process info blocks + DosGetInfoBlocks(NULL, &ppib); + + // Get full path of the executable + DosQueryModuleName(ppib->pib_hmte, sizeof( path ), path); + + // Truncate name part including last backslash + *strrchr(path, '\\') = 0; + + // Convert backslash to slash + _fnslashify(path); + + homedir = path; + } +#else + return NULL; +#endif + len = strlen(homedir) + strlen(config_dir) + 1; + if (filename == NULL) { + if ((buff = malloc(len)) == NULL) + return NULL; + sprintf(buff, "%s%s", homedir, config_dir); + } else { + len += strlen(filename) + 1; + if ((buff = malloc(len)) == NULL) + return NULL; + sprintf(buff, "%s%s/%s", homedir, config_dir, filename); + } + +#ifdef CONFIG_MACOSX_BUNDLE + if (stat(buff, &dummy)) { + + res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle()); + + if (res_url_ref&&bdl_url_ref) { + + res_url_path=malloc(maxlen); + bdl_url_path=malloc(maxlen); + + while (!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) { + maxlen*=2; + res_url_path=realloc(res_url_path, maxlen); + } + CFRelease(res_url_ref); + + while (!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) { + maxlen*=2; + bdl_url_path=realloc(bdl_url_path, maxlen); + } + CFRelease(bdl_url_ref); + + if (strcmp(res_url_path, bdl_url_path) == 0) + res_url_path = NULL; + } + + if (res_url_path&&filename) { + if ((strlen(filename)+strlen(res_url_path)+2)>maxlen) { + maxlen=strlen(filename)+strlen(res_url_path)+2; + } + free(buff); + buff = malloc(maxlen); + strcpy(buff, res_url_path); + + strcat(buff,"/"); + strcat(buff, filename); + } + } +#endif + mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); + return buff; +} + +#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) +void set_path_env(void) +{ + /*make our codec dirs available for LoadLibraryA()*/ + char win32path[MAX_PATH]; +#ifdef __CYGWIN__ + cygwin_conv_to_full_win32_path(BINARY_CODECS_PATH, win32path); +#else /*__CYGWIN__*/ + /* Expand to absolute path unless it's already absolute */ + if (!strstr(BINARY_CODECS_PATH,":") && BINARY_CODECS_PATH[0] != '\\') { + GetModuleFileNameA(NULL, win32path, MAX_PATH); + strcpy(strrchr(win32path, '\\') + 1, BINARY_CODECS_PATH); + } + else strcpy(win32path, BINARY_CODECS_PATH); +#endif /*__CYGWIN__*/ + mp_msg(MSGT_WIN32, MSGL_V, "Setting PATH to %s\n", win32path); + if (!SetEnvironmentVariableA("PATH", win32path)) + mp_msg(MSGT_WIN32, MSGL_WARN, "Cannot set PATH!"); +} +#endif /* (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) */ + +char *def_path = BINARY_CODECS_PATH; + +static int needs_free = 0; + +void SetCodecPath(const char *path) +{ + if (needs_free) + free(def_path); + if (path == 0) { + def_path = BINARY_CODECS_PATH; + needs_free = 0; + return; + } + def_path = malloc(strlen(path) + 1); + strcpy(def_path, path); + needs_free = 1; +} diff --git a/path.h b/path.h new file mode 100644 index 0000000000..fe7c0c6c85 --- /dev/null +++ b/path.h @@ -0,0 +1,30 @@ +/* + * Get path to config dir/file. + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPLAYER_PATH_H +#define MPLAYER_PATH_H + +extern char *def_path; + +char *get_path(const char *filename); +void set_path_env(void); +void SetCodecPath(const char *path); + +#endif /* MPLAYER_PATH_H */ diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index 4a7efe2724..c380e83895 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -44,7 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "help_mp.h" #include "m_option.h" #include "m_struct.h" -#include "get_path.h" +#include "path.h" #include "libavutil/avstring.h" #include "dvbin.h" -- cgit v1.2.3