Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
libbdplus
Commits
1fdc4c74
Commit
1fdc4c74
authored
Jan 21, 2015
by
anonymous
Browse files
Merge file changes from other libs
parent
bc9cadcc
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/file/configfile.c
View file @
1fdc4c74
...
...
@@ -25,6 +25,7 @@
#include "dirs.h"
#include "util/logging.h"
#include "util/macro.h"
#include "util/strutl.h"
#include <stdio.h>
...
...
@@ -76,15 +77,14 @@ int file_mkpath(const char *path)
return
result
;
}
const
char
*
file_get_cache_dir
(
void
)
char
*
file_get_cache_dir
(
void
)
{
static
const
char
*
dir
=
NULL
;
char
*
cache
=
file_get_cache_home
();
char
*
dir
;
if
(
!
dir
)
{
const
char
*
cache
=
file_get_cache_home
();
dir
=
str_printf
(
"%s/%s"
,
cache
?
cache
:
"/tmp/"
,
BDPLUS_DIR
);
file_mkpath
(
dir
);
}
dir
=
str_printf
(
"%s/%s"
,
cache
?
cache
:
"/tmp/"
,
BDPLUS_DIR
);
X_FREE
(
cache
);
file_mkpath
(
dir
);
return
dir
;
}
...
...
@@ -110,6 +110,7 @@ char *file_get_config_dir(const char *file)
{
char
*
dir
=
NULL
;
const
char
*
vm
;
char
*
config_home
;
const
char
*
base
;
vm
=
getenv
(
"BDPLUS_VM_ID"
);
...
...
@@ -118,8 +119,9 @@ char *file_get_config_dir(const char *file)
}
/* try home directory */
base
=
file_get_config_home
();
dir
=
_probe_config_dir
(
base
,
vm
,
file
);
config_home
=
file_get_config_home
();
dir
=
_probe_config_dir
(
config_home
,
vm
,
file
);
X_FREE
(
config_home
);
if
(
dir
)
{
return
dir
;
}
...
...
src/file/configfile.h
View file @
1fdc4c74
...
...
@@ -27,10 +27,10 @@
BD_PRIVATE
int
file_mkpath
(
const
char
*
path
);
BD_PRIVATE
c
onst
char
*
file_get_cache_dir
(
void
);
BD_PRIVATE
char
*
file_get_config_dir
(
const
char
*
file
);
BD_PRIVATE
c
har
*
file_get_cache_dir
(
void
)
BD_ATTR_MALLOC
;
BD_PRIVATE
char
*
file_get_config_dir
(
const
char
*
file
)
BD_ATTR_MALLOC
;
BD_PRIVATE
char
*
file_load
(
const
char
*
path
,
uint32_t
*
p_size
);
BD_PRIVATE
char
*
file_load
(
const
char
*
path
,
uint32_t
*
p_size
)
BD_ATTR_MALLOC
;
#endif
src/file/dirs.h
View file @
1fdc4c74
...
...
@@ -20,7 +20,7 @@
#ifndef BLURAY_DIRS_H
#define BLURAY_DIRS_H
#include
<
util/attributes.h
>
#include
"
util/attributes.h
"
#ifdef _WIN32
BD_PRIVATE
int
win32_mkdir
(
const
char
*
dir
);
...
...
@@ -30,9 +30,10 @@ BD_PRIVATE int win32_mkdir(const char *dir);
* Config, cache and data dirs
*/
BD_PRIVATE
const
char
*
file_get_config_home
(
void
);
BD_PRIVATE
const
char
*
file_get_config_system
(
const
char
*
dir
);
BD_PRIVATE
const
char
*
file_get_cache_home
(
void
);
BD_PRIVATE
const
char
*
file_get_data_home
(
void
);
BD_PRIVATE
char
*
file_get_config_home
(
void
)
BD_ATTR_MALLOC
;
BD_PRIVATE
char
*
file_get_cache_home
(
void
)
BD_ATTR_MALLOC
;
BD_PRIVATE
char
*
file_get_data_home
(
void
)
BD_ATTR_MALLOC
;
#endif
src/file/dirs_darwin.c
View file @
1fdc4c74
...
...
@@ -38,61 +38,37 @@
#define SYSTEM_CFG_DIR "/Library/Preferences"
const
char
*
file_get_config_home
(
void
)
char
*
file_get_config_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
BD_DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_data_home
(
void
)
char
*
file_get_data_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
BD_DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_cache_home
(
void
)
char
*
file_get_cache_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
BD_DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_config_system
(
const
char
*
dir
)
...
...
src/file/dirs_win32.c
View file @
1fdc4c74
...
...
@@ -42,33 +42,29 @@ int win32_mkdir(const char *dir)
return
_wmkdir
(
wdir
);
}
const
char
*
file_get_config_home
(
void
)
char
*
file_get_config_home
(
void
)
{
return
file_get_data_home
();
}
const
char
*
file_get_data_home
(
void
)
char
*
file_get_data_home
(
void
)
{
static
char
*
appdir
=
NULL
;
wchar_t
wdir
[
MAX_PATH
];
if
(
appdir
)
return
appdir
;
/* Get the "Application Data" folder for the user */
if
(
S_OK
==
SHGetFolderPathW
(
NULL
,
CSIDL_APPDATA
|
CSIDL_FLAG_CREATE
,
NULL
,
SHGFP_TYPE_CURRENT
,
wdir
))
{
int
len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
wdir
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
appdir
=
malloc
(
len
);
char
*
appdir
=
malloc
(
len
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
wdir
,
-
1
,
appdir
,
len
,
NULL
,
NULL
);
return
appdir
;
}
BD_
DEBUG
(
DBG_FILE
,
"Can't find user configuration directory !
\n
"
);
DEBUG
(
DBG_FILE
,
"Can't find user configuration directory !
\n
"
);
return
NULL
;
}
const
char
*
file_get_cache_home
(
void
)
char
*
file_get_cache_home
(
void
)
{
return
file_get_data_home
();
}
...
...
@@ -92,7 +88,7 @@ const char *file_get_config_system(const char *dir)
WideCharToMultiByte
(
CP_UTF8
,
0
,
wdir
,
-
1
,
appdir
,
len
,
NULL
,
NULL
);
return
appdir
;
}
else
{
BD_
DEBUG
(
DBG_FILE
,
"Can't find common configuration directory !
\n
"
);
DEBUG
(
DBG_FILE
,
"Can't find common configuration directory !
\n
"
);
return
NULL
;
}
}
else
{
...
...
src/file/dirs_xdg.c
View file @
1fdc4c74
...
...
@@ -41,76 +41,52 @@
#define SYSTEM_CFG_DIR "/etc/xdg"
const
char
*
file_get_config_home
(
void
)
char
*
file_get_config_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
xdg_home
=
getenv
(
"XDG_CONFIG_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
dir
=
str_printf
(
"%s"
,
xdg_home
);
}
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
const
char
*
xdg_home
=
getenv
(
"XDG_CONFIG_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
str_printf
(
"%s"
,
xdg_home
);
}
BD_DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CFG_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_data_home
(
void
)
char
*
file_get_data_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
xdg_home
=
getenv
(
"XDG_DATA_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
dir
=
str_printf
(
"%s"
,
xdg_home
);
}
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
const
char
*
xdg_home
=
getenv
(
"XDG_DATA_HOME"
);
if
(
xdg_home
&&
*
xdg_home
)
{
return
str_printf
(
"%s"
,
xdg_home
);
}
BD_DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_DATA_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_cache_home
(
void
)
char
*
file_get_cache_home
(
void
)
{
static
char
*
dir
=
NULL
;
static
int
init_done
=
0
;
if
(
!
init_done
)
{
init_done
=
1
;
const
char
*
xdg_cache
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
xdg_cache
&&
*
xdg_cache
)
{
return
dir
=
str_printf
(
"%s"
,
xdg_cache
);
}
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
dir
=
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
const
char
*
xdg_cache
=
getenv
(
"XDG_CACHE_HOME"
);
if
(
xdg_cache
&&
*
xdg_cache
)
{
return
str_printf
(
"%s"
,
xdg_cache
);
}
BD_DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
const
char
*
user_home
=
getenv
(
"HOME"
);
if
(
user_home
&&
*
user_home
)
{
return
str_printf
(
"%s/%s"
,
user_home
,
USER_CACHE_DIR
);
}
return
dir
;
DEBUG
(
DBG_FILE
,
"Can't find user home directory ($HOME) !
\n
"
);
return
NULL
;
}
const
char
*
file_get_config_system
(
const
char
*
dir
)
...
...
src/libbdplus/bdplus.c
View file @
1fdc4c74
...
...
@@ -91,8 +91,11 @@ int32_t bdplus_get_code_date(bdplus_t *plus)
static
char
*
_slots_file
(
void
)
{
const
char
*
base
=
file_get_cache_dir
();
return
str_printf
(
"%s/slots.bin"
,
base
?
base
:
"/tmp/"
);
char
*
base
=
file_get_cache_dir
();
char
*
result
;
result
=
str_printf
(
"%s/slots.bin"
,
base
?
base
:
"/tmp/"
);
X_FREE
(
base
);
return
result
;
}
static
void
_load_slots
(
bdplus_t
*
plus
)
...
...
src/libbdplus/internal.c
View file @
1fdc4c74
...
...
@@ -68,11 +68,12 @@ int crypto_init()
char
*
bdplus_disc_cache_file
(
bdplus_t
*
plus
,
const
char
*
file
)
{
const
char
*
base
=
file_get_cache_dir
();
char
*
base
=
file_get_cache_dir
();
char
vid_str
[
33
];
char
*
result
;
print_hex
(
vid_str
,
plus
->
volumeID
,
16
);
result
=
str_printf
(
"%s/%s/%s"
,
base
?
base
:
"/tmp/"
,
vid_str
,
file
);
X_FREE
(
base
);
file_mkpath
(
result
);
return
result
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment