Skip to content

Commit

Permalink
More cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed Mar 7, 2023
1 parent 596e84a commit c69552c
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 194 deletions.
20 changes: 1 addition & 19 deletions display.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@

#include "snes9x.h"

enum s9x_getdirtype
{
DEFAULT_DIR = 0,
HOME_DIR,
ROMFILENAME_DIR,
ROM_DIR,
SRAM_DIR,
SNAPSHOT_DIR,
SCREENSHOT_DIR,
SPC_DIR,
CHEAT_DIR,
PATCH_DIR,
BIOS_DIR,
LOG_DIR,
SAT_DIR,
LAST_DIR
};

void S9xUsage (void);
char * S9xParseArgs (char **, int);
void S9xParseArgsForCheats (char **, int);
Expand All @@ -45,9 +27,9 @@ bool8 S9xOpenSnapshotFile (const char *, bool8, STREAM *);
void S9xCloseSnapshotFile (STREAM);
const char * S9xStringInput (const char *);
std::string S9xGetDirectory (enum s9x_getdirtype);
std::string S9xGetFilename (std::string, enum s9x_getdirtype);
std::string S9xGetFilenameInc (std::string, enum s9x_getdirtype);
std::string S9xBasename (std::string);
std::string S9xBasenameNoExt (std::string);

// Routines the port has to implement if it uses command-line

Expand Down
30 changes: 28 additions & 2 deletions fscompat.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include <cstring>
#include "port.h"
#include <string>
#include <string.h>

#include "display.h"
#include "fscompat.h"
#include "port.h"
#include "memmap.h"

using std::string;

Expand All @@ -19,6 +22,29 @@ std::string makepath(const SplitPath &path)
return makepath(path.drive, path.dir, path.stem, path.ext);
}

std::string S9xGetFilename(string filename, string ext, enum s9x_getdirtype dirtype)
{
auto path = splitpath(filename);
auto dir = S9xGetDirectory(dirtype);
return makepath(path.drive, dir, path.stem, ext);
}

std::string S9xGetFilename(string ext, enum s9x_getdirtype dirtype)
{
return S9xGetFilename(Memory.ROMFilename, ext, dirtype);
}

std::string S9xBasename(std::string filename)
{
auto path = splitpath(filename);
return path.stem + path.ext;
}

std::string S9xBasenameNoExt(std::string filename)
{
return splitpath(filename).stem;
}

#if __cplusplus >= 201703L
#include <filesystem>
namespace fs = std::filesystem;
Expand Down
18 changes: 0 additions & 18 deletions gtk/src/gtk_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,6 @@ std::string S9xGetDirectory(enum s9x_getdirtype dirtype)
return dirname;
}

std::string S9xGetFilename(std::string ex, enum s9x_getdirtype dirtype)
{
fs::path path(S9xGetDirectory(dirtype));
path /= fs::path(Memory.ROMFilename).filename();
path.replace_extension(ex);
return path.string();
}

std::string S9xBasename(std::string filename)
{
return fs::path(filename).filename().string();
}

std::string S9xBasenameNoExt(std::string f)
{
return fs::path(f).stem();
}

bool8 S9xOpenSnapshotFile(const char *filename, bool8 read_only, STREAM *file)
{
if (read_only)
Expand Down
8 changes: 1 addition & 7 deletions gtk/src/gtk_s9xwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ const char *markup = _(R"(<b>Information for %s</b>
char output[2048];

snprintf(output, 2048, markup,
Memory.ROMFilename,
Memory.ROMFilename.c_str(),
Memory.ROMName,
Memory.ROMSpeed,
((Memory.ROMSpeed & 0x10) != 0) ? "FastROM" : "SlowROM",
Expand Down Expand Up @@ -1020,12 +1020,6 @@ void Snes9xWindow::reset_screensaver()
XResetScreenSaver(GDK_DISPLAY_XDISPLAY(gdk_display));
}
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_WINDOW(gdk_window))
{
// TODO screensaver for wayland
}
#endif

config->screensaver_needs_reset = false;
}
Expand Down
Loading

0 comments on commit c69552c

Please sign in to comment.