Move rarch_extract_directory to file_path.c and rename it

fill_pathname_basedir
This commit is contained in:
Twinaphex 2012-07-28 20:43:34 +02:00
parent eff526076b
commit f4559bf636
6 changed files with 21 additions and 18 deletions

View File

@ -39,18 +39,3 @@ const char * rarch_convert_wchar_to_const_char(const wchar_t * wstr)
wcstombs(str, wstr, sizeof(str));
return str;
}
void rarch_extract_directory(char *buf, const char *path, size_t size)
{
strncpy(buf, path, size - 1);
buf[size - 1] = '\0';
char *base = strrchr(buf, '/');
if (!base)
base = strrchr(buf, '\\');
if (base)
*base = '\0';
else
buf[0] = '\0';
}

View File

@ -80,6 +80,5 @@ extern default_paths_t default_paths;
void rarch_convert_char_to_wchar(wchar_t *buf, const char * str, size_t size);
const char * rarch_convert_wchar_to_const_char(const wchar_t * wstr);
void rarch_extract_directory(char *buf, const char *path, size_t size);
#endif

View File

@ -23,6 +23,9 @@
// sane name.
#ifndef IS_SALAMANDER
// Transforms a library id to a name suitable as a pathname.
static void rarch_console_name_from_id(char *name, size_t size)
{
if (size == 0)
@ -150,7 +153,6 @@ bool rarch_manage_libretro_extension_supported(const char *filename)
return ext_supported;
}
// Transforms a library id to a name suitable as a pathname.
#endif

View File

@ -64,7 +64,7 @@ void rarch_console_load_game_wrap(const char *path, unsigned extract_zip_mode, u
#ifdef HAVE_ZLIB
if(extract_zip_cond)
{
rarch_extract_directory(dir_path_temp, rom_path_temp, sizeof(dir_path_temp));
fill_pathname_basedir(dir_path_temp, rom_path_temp, sizeof(dir_path_temp));
rarch_extract_zipfile(rom_path_temp, dir_path_temp, first_file, sizeof(first_file), extract_zip_mode);
#ifndef GEKKO

3
file.h
View File

@ -94,4 +94,7 @@ void fill_pathname_dir(char *in_dir, const char *in_basename, const char *replac
// Copies basename of in_path into out_path.
void fill_pathname_base(char *out_path, const char *in_path, size_t size);
// Copies base directory of in_path into out_path.
void fill_pathname_basedir(char *out_path, const char *in_path, size_t size);
#endif

View File

@ -386,3 +386,17 @@ void fill_pathname_base(char *out_dir, const char *in_path, size_t size)
rarch_assert(strlcpy(out_dir, ptr, size) < size);
}
void fill_pathname_basedir(char *out_dir, const char *in_path, size_t size)
{
strncpy(out_dir, in_path, size - 1);
out_dir[size - 1] = '\0';
char *base = strrchr(out_dir, '/');
if (!base)
base = strrchr(out_dir, '\\');
if (base)
*base = '\0';
else
out_dir[0] = '\0';
}