RetroArch/paths.c
2016-09-17 12:10:46 +02:00

62 lines
2.0 KiB
C

/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2016 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <compat/strl.h>
#include <file/file_path.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "paths.h"
#include "runloop.h"
void path_set_basename(const char *path)
{
char *dst = NULL;
global_t *global = global_get_ptr();
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)path);
strlcpy(global->name.base, path, sizeof(global->name.base));
#ifdef HAVE_COMPRESSION
/* Removing extension is a bit tricky for compressed files.
* Basename means:
* /file/to/path/game.extension should be:
* /file/to/path/game
*
* Two things to consider here are: /file/to/path/ is expected
* to be a directory and "game" is a single file. This is used for
* states and srm default paths.
*
* For compressed files we have:
*
* /file/to/path/comp.7z#game.extension and
* /file/to/path/comp.7z#folder/game.extension
*
* The choice I take here is:
* /file/to/path/game as basename. We might end up in a writable
* directory then and the name of srm and states are meaningful.
*
*/
path_basedir(global->name.base);
fill_pathname_dir(global->name.base, path, "", sizeof(global->name.base));
#endif
if ((dst = strrchr(global->name.base, '.')))
*dst = '\0';
}