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;
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 );
}
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 );
}
#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
************************************************************************
#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
***********************************************************************/
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__
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, '.');
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, '.');