Commit 84c29825 authored by npzacs's avatar npzacs
Browse files

Use correct directory separator

parent 8aeb28a5
......@@ -26,9 +26,15 @@
#include <stdint.h>
//#ifdef __LINUX__
#define DIR_SEP "/"
//#endif
#ifdef _WIN32
# define DIR_SEP "\\"
#else
# define DIR_SEP "/"
#endif
/*
* file access
*/
#define file_close(X) X->close(X)
#define file_seek(X,Y,Z) X->seek(X,Y,Z)
......
......@@ -33,6 +33,11 @@
#ifdef _WIN32
# define mkdir(p,m) win32_mkdir(p)
# define DIR_SEP_CHAR '\\'
# define DIR_SEP "\\"
#else
# define DIR_SEP_CHAR '/'
# define DIR_SEP "/"
#endif
......@@ -52,10 +57,10 @@ static int _mkpath(const char *path)
char *dir = str_printf("%s", path);
char *end = dir;
while (*end == '/')
while (*end == DIR_SEP_CHAR)
end++;
while ((end = strchr(end, '/'))) {
while ((end = strchr(end, DIR_SEP_CHAR))) {
*end = 0;
if (stat(dir, &s) != 0 || !S_ISDIR(s.st_mode)) {
......@@ -68,7 +73,7 @@ static int _mkpath(const char *path)
}
}
*end++ = '/';
*end++ = DIR_SEP_CHAR;
}
X_FREE(dir);
......@@ -112,7 +117,7 @@ static char *_config_file_user(const char *file_name)
return NULL;
}
return str_printf("%s/%s/%s", cfg_dir, CFG_DIR, file_name);
return str_printf("%s"DIR_SEP"%s"DIR_SEP"%s", cfg_dir, CFG_DIR, file_name);
}
static FILE *_open_cfg_file_user(const char *file_name, char **path, const char *mode)
......@@ -149,7 +154,7 @@ static FILE *_open_cfg_file_system(const char *file_name, char **path)
while (NULL != (dir = file_get_config_system(dir))) {
char *cfg_file = str_printf("%s/%s/%s", dir, CFG_DIR, file_name);
char *cfg_file = str_printf("%s"DIR_SEP"%s"DIR_SEP"%s", dir, CFG_DIR, file_name);
FILE *fp = fopen(cfg_file, "r");
if (fp) {
......@@ -342,7 +347,7 @@ static char *_keycache_file(const char *type, const uint8_t *disc_id)
hex_array_to_hexstring(disc_id_str, disc_id, 20);
return str_printf("%s/%s/%s/%s", cache_dir, CFG_DIR, type, disc_id_str);
return str_printf("%s"DIR_SEP"%s"DIR_SEP"%s"DIR_SEP"%s", cache_dir, CFG_DIR, type, disc_id_str);
}
int keycache_save(const char *type, const uint8_t *disc_id, const uint8_t *key, unsigned int len)
......@@ -424,7 +429,7 @@ static char *_cache_file(const char *name)
return NULL;
}
return str_printf("%s/%s/%s", cache_dir, CFG_DIR, name);
return str_printf("%s"DIR_SEP"%s"DIR_SEP"%s", cache_dir, CFG_DIR, name);
}
int cache_save(const char *name, uint32_t version, const void *data, uint32_t len)
......
......@@ -383,7 +383,7 @@ static AACS_FILE_H *_file_open(AACS *aacs, const char *file)
return aacs->fopen(aacs->fopen_handle, file);
}
f_name = str_printf("%s/%s", aacs->path, file);
f_name = str_printf("%s" DIR_SEP "%s", aacs->path, file);
fp = file_open(f_name, "rb");
X_FREE(f_name);
......@@ -395,7 +395,7 @@ static MKB *_mkb_open(AACS *aacs)
AACS_FILE_H *fp;
MKB *mkb;
fp = _file_open(aacs, "AACS/MKB_RO.inf");
fp = _file_open(aacs, "AACS" DIR_SEP "MKB_RO.inf");
if (!fp) {
DEBUG(DBG_AACS | DBG_CRIT, "Error opening MKB file (AACS/MKB_RO.inf)\n");
return NULL;
......@@ -747,7 +747,7 @@ static int _calc_uks(AACS *aacs, config_file *cf)
DEBUG(DBG_AACS, "Calculate CPS unit keys...\n");
fp = _file_open(aacs, "AACS/Unit_Key_RO.inf");
fp = _file_open(aacs, "AACS" DIR_SEP "Unit_Key_RO.inf");
if (!fp) {
DEBUG(DBG_AACS | DBG_CRIT, "Error opening unit key file (AACS/Unit_Key_RO.inf)\n");
return AACS_ERROR_CORRUPTED_DISC;
......@@ -813,7 +813,7 @@ static int _calc_title_hash(AACS *aacs)
int64_t f_size;
int result = AACS_SUCCESS;
fp = _file_open(aacs, "AACS/Unit_Key_RO.inf");
fp = _file_open(aacs, "AACS" DIR_SEP "Unit_Key_RO.inf");
if (!fp) {
DEBUG(DBG_AACS | DBG_CRIT, "Error opening unit key file (AACS/Unit_Key_RO.inf)\n");
return AACS_ERROR_CORRUPTED_DISC;
......@@ -846,7 +846,7 @@ static int _get_bus_encryption_enabled(AACS *aacs)
uint8_t buf[2];
int bee = 0;
fp = _file_open(aacs, "AACS/Content000.cer");
fp = _file_open(aacs, "AACS" DIR_SEP "Content000.cer");
if (!fp) {
DEBUG(DBG_AACS | DBG_CRIT, "Unable to open content certificate (AACS/Content000.cer)\n");
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment