fs: Export function to get basename from path

This commit is contained in:
Joel16 2021-06-05 17:34:58 -04:00
parent 48fa81e646
commit f4130b20f2
4 changed files with 8 additions and 4 deletions

View File

@ -14,8 +14,8 @@ VERSION_MAJOR := 4
VERSION_MINOR := 0
VERSION_MICRO := 0
INCDIR = ../libs/include ../libs/include/ogg ../libs/include/opus include
CFLAGS = -Os -G0 -Wall -ffast-math -fno-rtti -fno-exceptions -Wno-narrowing \
INCDIR = ../libs/include ../libs/include/opus include
CFLAGS = -Os -G0 -Wall -ffast-math -fno-rtti -fno-exceptions -Wno-narrowing -Wno-unused-variable \
-DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO)
CXXFLAGS = $(CFLAGS) -std=gnu++17
ASFLAGS := $(CFLAGS)

View File

@ -35,6 +35,7 @@ namespace FS {
int GetDirList(const std::string &path, std::vector<SceIoDirent> &entries);
int ChangeDirNext(const std::string &path, std::vector<SceIoDirent> &entries);
int ChangeDirPrev(std::vector<SceIoDirent> &entries);
std::string GetFilename(const std::string &path);
void Copy(SceIoDirent *entry, const std::string &path);
int Paste(void);
int Move(void);

View File

@ -267,6 +267,10 @@ namespace FS {
return FS::ChangeDir(parent_path.empty()? cfg.cwd : parent_path, entries);
}
std::string GetFilename(const std::string &path) {
return std::filesystem::path(path).filename().u8string();
}
static int CopyFile(const std::string &src_path, const std::string &dest_path) {
int ret = 0;

View File

@ -1,6 +1,5 @@
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <malloc.h>
#include <pspiofilemgr.h>
#include <pspthreadman.h>
@ -344,7 +343,7 @@ namespace TextViewer {
std::string new_line = std::string();
TEXT_VIEWER_STATE state = STATE_EDIT;
std::string filename = std::filesystem::path(path.data()).filename();
std::string filename = FS::GetFilename(path);
static int selection = 0;
static const std::string prompt = "Do you wish to save your changes?";