mirror of https://github.com/mpv-player/mpv
cosmetics: Fix up whitespace, indentation and similar things.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24287 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
38af490489
commit
b2481156c3
57
get_path.c
57
get_path.c
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get path to config dir/file.
|
* Get path to config dir/file.
|
||||||
*
|
*
|
||||||
|
@ -6,7 +5,6 @@
|
||||||
* Returns the pointer to the ALLOCATED buffer containing the
|
* Returns the pointer to the ALLOCATED buffer containing the
|
||||||
* zero terminated path string. This buffer has to be FREED
|
* zero terminated path string. This buffer has to be FREED
|
||||||
* by the caller.
|
* by the caller.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -28,8 +26,8 @@
|
||||||
char *get_path(const char *filename){
|
char *get_path(const char *filename){
|
||||||
char *homedir;
|
char *homedir;
|
||||||
char *buff;
|
char *buff;
|
||||||
#if defined(__MINGW32__)
|
#ifdef __MINGW32__
|
||||||
static char *config_dir = "/mplayer";
|
static char *config_dir = "/mplayer";
|
||||||
#else
|
#else
|
||||||
static char *config_dir = "/.mplayer";
|
static char *config_dir = "/.mplayer";
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,18 +44,21 @@ char *get_path(const char *filename){
|
||||||
if ((homedir = getenv("MPLAYER_HOME")) != NULL)
|
if ((homedir = getenv("MPLAYER_HOME")) != NULL)
|
||||||
config_dir = "";
|
config_dir = "";
|
||||||
else if ((homedir = getenv("HOME")) == NULL)
|
else if ((homedir = getenv("HOME")) == NULL)
|
||||||
#if defined(__MINGW32__)||defined(__CYGWIN__) /*hack to get fonts etc. loaded outside of cygwin environment*/
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||||
|
/* Hack to get fonts etc. loaded outside of Cygwin environment. */
|
||||||
{
|
{
|
||||||
int i,imax=0;
|
int i,imax=0;
|
||||||
char exedir[260];
|
char exedir[260];
|
||||||
GetModuleFileNameA(NULL, exedir, 260);
|
GetModuleFileNameA(NULL, exedir, 260);
|
||||||
for(i=0; i< strlen(exedir);i++)if(exedir[i] =='\\'){exedir[i]='/';imax=i;}
|
for (i=0; i< strlen(exedir); i++)
|
||||||
exedir[imax]='\0';
|
if (exedir[i] =='\\')
|
||||||
homedir = exedir;
|
{exedir[i]='/'; imax=i;}
|
||||||
|
exedir[imax]='\0';
|
||||||
|
homedir = exedir;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
len = strlen(homedir) + strlen(config_dir) + 1;
|
len = strlen(homedir) + strlen(config_dir) + 1;
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
if ((buff = malloc(len)) == NULL)
|
if ((buff = malloc(len)) == NULL)
|
||||||
|
@ -71,40 +72,40 @@ char *get_path(const char *filename){
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MACOSX_BUNDLE
|
#ifdef MACOSX_BUNDLE
|
||||||
if(stat(buff, &dummy)) {
|
if (stat(buff, &dummy)) {
|
||||||
|
|
||||||
res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
|
res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
|
||||||
bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
|
|
||||||
if(res_url_ref&&bdl_url_ref) {
|
if (res_url_ref&&bdl_url_ref) {
|
||||||
|
|
||||||
res_url_path=malloc(maxlen);
|
res_url_path=malloc(maxlen);
|
||||||
bdl_url_path=malloc(maxlen);
|
bdl_url_path=malloc(maxlen);
|
||||||
|
|
||||||
while(!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) {
|
while (!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) {
|
||||||
maxlen*=2;
|
maxlen*=2;
|
||||||
res_url_path=realloc(res_url_path, maxlen);
|
res_url_path=realloc(res_url_path, maxlen);
|
||||||
}
|
}
|
||||||
CFRelease(res_url_ref);
|
CFRelease(res_url_ref);
|
||||||
|
|
||||||
while(!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) {
|
while (!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) {
|
||||||
maxlen*=2;
|
maxlen*=2;
|
||||||
bdl_url_path=realloc(bdl_url_path, maxlen);
|
bdl_url_path=realloc(bdl_url_path, maxlen);
|
||||||
}
|
}
|
||||||
CFRelease(bdl_url_ref);
|
CFRelease(bdl_url_ref);
|
||||||
|
|
||||||
if( strcmp(res_url_path, bdl_url_path) == 0)
|
if (strcmp(res_url_path, bdl_url_path) == 0)
|
||||||
res_url_path = NULL;
|
res_url_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res_url_path&&filename) {
|
if (res_url_path&&filename) {
|
||||||
if((strlen(filename)+strlen(res_url_path)+2)>maxlen) {
|
if ((strlen(filename)+strlen(res_url_path)+2)>maxlen) {
|
||||||
maxlen=strlen(filename)+strlen(res_url_path)+2;
|
maxlen=strlen(filename)+strlen(res_url_path)+2;
|
||||||
}
|
}
|
||||||
free(buff);
|
free(buff);
|
||||||
buff = malloc(maxlen);
|
buff = malloc(maxlen);
|
||||||
strcpy(buff, res_url_path);
|
strcpy(buff, res_url_path);
|
||||||
|
|
||||||
strcat(buff,"/");
|
strcat(buff,"/");
|
||||||
strcat(buff, filename);
|
strcat(buff, filename);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +131,7 @@ void set_path_env()
|
||||||
#endif /*USE_REALCODECS*/
|
#endif /*USE_REALCODECS*/
|
||||||
#else /*__CYGWIN__*/
|
#else /*__CYGWIN__*/
|
||||||
/* Expand to absolute path unless it's already absolute */
|
/* Expand to absolute path unless it's already absolute */
|
||||||
if(!strstr(WIN32_PATH,":") && WIN32_PATH[0] != '\\'){
|
if (!strstr(WIN32_PATH,":") && WIN32_PATH[0] != '\\'){
|
||||||
GetModuleFileNameA(NULL, win32path, MAX_PATH);
|
GetModuleFileNameA(NULL, win32path, MAX_PATH);
|
||||||
strcpy(strrchr(win32path, '\\') + 1, WIN32_PATH);
|
strcpy(strrchr(win32path, '\\') + 1, WIN32_PATH);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +139,7 @@ void set_path_env()
|
||||||
strcpy(tmppath,win32path);
|
strcpy(tmppath,win32path);
|
||||||
#ifdef USE_REALCODECS
|
#ifdef USE_REALCODECS
|
||||||
/* Expand to absolute path unless it's already absolute */
|
/* Expand to absolute path unless it's already absolute */
|
||||||
if(!strstr(REALCODEC_PATH,":") && REALCODEC_PATH[0] != '\\'){
|
if (!strstr(REALCODEC_PATH,":") && REALCODEC_PATH[0] != '\\'){
|
||||||
GetModuleFileNameA(NULL, realpath, MAX_PATH);
|
GetModuleFileNameA(NULL, realpath, MAX_PATH);
|
||||||
strcpy(strrchr(realpath, '\\') + 1, REALCODEC_PATH);
|
strcpy(strrchr(realpath, '\\') + 1, REALCODEC_PATH);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue