summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-02-22 05:21:04 +0000
committerjstebbins <[email protected]>2014-02-22 05:21:04 +0000
commit993d19bcffe30ae1213ebe040083a86b2c33300f (patch)
tree95a574db516d36610edb1fcbfd160d4e18351150
parentab50e34327aea45ed0a1b258d07bd269dcc39a9e (diff)
libhb: clean up handling dir directory separator
title->name was getting set to an empty string in some cases due to looking for the wrong directory separator. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6057 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/bd.c5
-rw-r--r--libhb/dvd.c5
-rw-r--r--libhb/dvdnav.c5
-rw-r--r--libhb/ports.c21
-rw-r--r--libhb/ports.h7
-rw-r--r--libhb/stream.c4
6 files changed, 42 insertions, 5 deletions
diff --git a/libhb/bd.c b/libhb/bd.c
index 9cd9d6ef1..586a1fa7b 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -253,11 +253,14 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration )
char * p_cur, * p_last = d->path;
for( p_cur = d->path; *p_cur; p_cur++ )
{
- if( p_cur[0] == '/' && p_cur[1] )
+ if( IS_DIR_SEP(p_cur[0]) && p_cur[1] )
{
p_last = &p_cur[1];
}
}
+ char *dot_term = strrchr(p_last, '.');
+ if (dot_term)
+ *dot_term = '\0';
snprintf( title->name, sizeof( title->name ), "%s", p_last );
strncpy( title->path, d->path, 1024 );
title->path[1023] = 0;
diff --git a/libhb/dvd.c b/libhb/dvd.c
index 7fb3830fb..628585b31 100644
--- a/libhb/dvd.c
+++ b/libhb/dvd.c
@@ -187,11 +187,14 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
char * p_cur, * p_last = d->path;
for( p_cur = d->path; *p_cur; p_cur++ )
{
- if( p_cur[0] == '/' && p_cur[1] )
+ if( IS_DIR_SEP(p_cur[0]) && p_cur[1] )
{
p_last = &p_cur[1];
}
}
+ char *dot_term = strrchr(p_last, '.');
+ if (dot_term)
+ *dot_term = '\0';
snprintf( title->name, sizeof( title->name ), "%s", p_last );
}
diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c
index 888289b60..081116c3b 100644
--- a/libhb/dvdnav.c
+++ b/libhb/dvdnav.c
@@ -334,11 +334,14 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
char * p_cur, * p_last = d->path;
for( p_cur = d->path; *p_cur; p_cur++ )
{
- if( p_cur[0] == '/' && p_cur[1] )
+ if( IS_DIR_SEP(p_cur[0]) && p_cur[1] )
{
p_last = &p_cur[1];
}
}
+ char *dot_term = strrchr(p_last, '.');
+ if (dot_term)
+ *dot_term = '\0';
snprintf( title->name, sizeof( title->name ), "%s", p_last );
}
diff --git a/libhb/ports.c b/libhb/ports.c
index 6348ceb9d..bb7c235a2 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -626,6 +626,27 @@ struct dirent * hb_readdir(HB_DIR *dir)
#endif
}
+void hb_rewinddir(HB_DIR *dir)
+{
+#ifdef SYS_MINGW
+ _wrewinddir(dir->wdir);
+#else
+ return rewinddir(dir);
+#endif
+}
+
+char * hb_strr_dir_sep(const char *path)
+{
+#ifdef SYS_MINGW
+ char *sep = strrchr(path, '/');
+ if (sep == NULL)
+ sep = strrchr(path, '\\');
+ return sep;
+#else
+ return strrchr(path, '/');
+#endif
+}
+
/************************************************************************
* hb_mkdir
************************************************************************
diff --git a/libhb/ports.h b/libhb/ports.h
index f55cac8c9..771a233a7 100644
--- a/libhb/ports.h
+++ b/libhb/ports.h
@@ -12,10 +12,15 @@
#if defined(_WIN32)
#define DIR_SEP_STR "\\"
+#define DIR_SEP_CHAR '\\'
+#define IS_DIR_SEP(c) (c == '\\' || c == '/')
#else
#define DIR_SEP_STR "/"
+#define DIR_SEP_CHAR '/'
+#define IS_DIR_SEP(c) (c == '/')
#endif
+
/************************************************************************
* CPU info utilities
***********************************************************************/
@@ -66,10 +71,12 @@ typedef struct stat hb_stat_t;
HB_DIR* hb_opendir(char *path);
int hb_closedir(HB_DIR *dir);
+void hb_rewinddir(HB_DIR *dir);
struct dirent * hb_readdir(HB_DIR *dir);
int hb_mkdir(char * name);
int hb_stat(const char *path, hb_stat_t *sb);
FILE * hb_fopen(const char *path, const char *mode);
+char * hb_strr_dir_sep(const char *path);
#ifdef __LIBHB__
diff --git a/libhb/stream.c b/libhb/stream.c
index 43f155fd4..a48d339f1 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -1042,7 +1042,7 @@ hb_title_t * hb_stream_title_scan(hb_stream_t *stream, hb_title_t * title)
title->index = 1;
// Copy part of the stream path to the title name
- char *sep = strrchr(stream->path, '/');
+ char *sep = hb_strr_dir_sep(stream->path);
if (sep)
strcpy(title->name, sep+1);
char *dot_term = strrchr(title->name, '.');
@@ -5361,7 +5361,7 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title )
title->index = 1;
// Copy part of the stream path to the title name
- char *sep = strrchr(stream->path, '/');
+ char *sep = hb_strr_dir_sep(stream->path);
if (sep)
strcpy(title->name, sep+1);
char *dot_term = strrchr(title->name, '.');