summaryrefslogtreecommitdiffstats
path: root/path.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-05 17:02:04 +0100
committerwm4 <wm4@nowhere>2012-11-12 20:06:14 +0100
commitd4bdd0473d6f43132257c9fb3848d829755167a3 (patch)
tree8021c2f7da1841393c8c832105e20cd527826d6c /path.c
parentbd48deba77bd5582c5829d6fe73a7d2571088aba (diff)
downloadmpv-d4bdd0473d6f43132257c9fb3848d829755167a3.tar.bz2
mpv-d4bdd0473d6f43132257c9fb3848d829755167a3.tar.xz
Rename directories, move files (step 1 of 2) (does not compile)
Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.
Diffstat (limited to 'path.c')
-rw-r--r--path.c207
1 files changed, 0 insertions, 207 deletions
diff --git a/path.c b/path.c
deleted file mode 100644
index 6002189225..0000000000
--- a/path.c
+++ /dev/null
@@ -1,207 +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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include "config.h"
-#include "mp_msg.h"
-#include "path.h"
-
-#ifdef CONFIG_MACOSX_BUNDLE
-#include <CoreFoundation/CoreFoundation.h>
-#include <unistd.h>
-#elif defined(__MINGW32__)
-#include <windows.h>
-#elif defined(__CYGWIN__)
-#include <windows.h>
-#include <sys/cygwin.h>
-#endif
-
-#include "talloc.h"
-
-#include "osdep/io.h"
-
-char *get_path(const char *filename){
- char *homedir;
- char *buff;
-#ifdef __MINGW32__
- static char *config_dir = "/mpv";
-#else
- static char *config_dir = "/.mpv";
-#endif
-#if defined(__MINGW32__) || defined(__CYGWIN__)
- char exedir[260];
-#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("MPV_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;
- len = (int)GetModuleFileNameA(NULL, exedir, 260);
- for (i=0; i < len; i++)
- if (exedir[i] =='\\')
- {exedir[i]='/'; imax=i;}
- exedir[imax]='\0';
- homedir = exedir;
- }
-#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;
-}
-
-char *mp_basename(const char *path)
-{
- char *s;
-
-#if HAVE_DOS_PATHS
- s = strrchr(path, '\\');
- if (s)
- path = s + 1;
- s = strrchr(path, ':');
- if (s)
- path = s + 1;
-#endif
- s = strrchr(path, '/');
- return s ? s + 1 : (char *)path;
-}
-
-struct bstr mp_dirname(const char *path)
-{
- struct bstr ret = {(uint8_t *)path, mp_basename(path) - path};
- if (ret.len == 0)
- return bstr0(".");
- return ret;
-}
-
-char *mp_path_join(void *talloc_ctx, struct bstr p1, struct bstr p2)
-{
- if (p1.len == 0)
- return bstrdup0(talloc_ctx, p2);
- if (p2.len == 0)
- return bstrdup0(talloc_ctx, p1);
-
-#if HAVE_DOS_PATHS
- if (p2.len >= 2 && p2.start[1] == ':'
- || p2.start[0] == '\\' || p2.start[0] == '/')
-#else
- if (p2.start[0] == '/')
-#endif
- return bstrdup0(talloc_ctx, p2); // absolute path
-
- bool have_separator;
- int endchar1 = p1.start[p1.len - 1];
-#if HAVE_DOS_PATHS
- have_separator = endchar1 == '/' || endchar1 == '\\'
- || p1.len == 2 && endchar1 == ':'; // "X:" only
-#else
- have_separator = endchar1 == '/';
-#endif
-
- return talloc_asprintf(talloc_ctx, "%.*s%s%.*s", BSTR_P(p1),
- have_separator ? "" : "/", BSTR_P(p2));
-}
-
-bool mp_path_exists(const char *path)
-{
- struct stat st;
- return mp_stat(path, &st) == 0;
-}
-
-bool mp_path_isdir(const char *path)
-{
- struct stat st;
- return mp_stat(path, &st) == 0 && S_ISDIR(st.st_mode);
-}