mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-27 02:50:32 +00:00
13ad9644a2
byuu says: Changelog: - hiro: BrowserDialog can navigate up to drive selection on Windows - nall: (file,path,dir,base,prefix,suffix)name => Location::(file,path,dir,base,prefix,suffix) - higan/tomoko: rename audio filter label from "Sinc" to "IIR - Biquad" - higan/tomoko: allow loading files via icarus on the command-line once again - higan/tomoko: (begrudging) quick hack to fix presentation window focus on startup - higan/audio: don't divide output audio volume by number of streams - processor/r65816: fix a regression in (read,write)DB; fixes Taz-Mania - fixed compilation regressions on Windows and Linux I'm happy with where we are at with code cleanups and stability, so I'd like to release v100. But even though I'm not assigning any special significance to this version, we should probably test it more thoroughly first.
73 lines
2.3 KiB
C++
73 lines
2.3 KiB
C++
#pragma once
|
|
|
|
namespace nall { namespace Location {
|
|
|
|
// (/parent/child.type/)
|
|
// (/parent/child.type/)name.type
|
|
inline auto path(string_view self) -> string {
|
|
const char* p = self.data() + self.size() - 1;
|
|
for(int offset = self.size() - 1; offset >= 0; offset--, p--) {
|
|
if(*p == '/') return slice(self, 0, offset + 1);
|
|
}
|
|
return ""; //no path found
|
|
}
|
|
|
|
// /parent/child.type/()
|
|
// /parent/child.type/(name.type)
|
|
inline auto file(string_view self) -> string {
|
|
const char* p = self.data() + self.size() - 1;
|
|
for(int offset = self.size() - 1; offset >= 0; offset--, p--) {
|
|
if(*p == '/') return slice(self, offset + 1);
|
|
}
|
|
return self; //no path found
|
|
}
|
|
|
|
// (/parent/)child.type/
|
|
// (/parent/child.type/)name.type
|
|
inline auto dir(string_view self) -> string {
|
|
const char* p = self.data() + self.size() - 1, *last = p;
|
|
for(int offset = self.size() - 1; offset >= 0; offset--, p--) {
|
|
if(*p == '/' && p == last) continue;
|
|
if(*p == '/') return slice(self, 0, offset + 1);
|
|
}
|
|
return ""; //no path found
|
|
}
|
|
|
|
// /parent/(child.type/)
|
|
// /parent/child.type/(name.type)
|
|
inline auto base(string_view self) -> string {
|
|
const char* p = self.data() + self.size() - 1, *last = p;
|
|
for(int offset = self.size() - 1; offset >= 0; offset--, p--) {
|
|
if(*p == '/' && p == last) continue;
|
|
if(*p == '/') return slice(self, offset + 1);
|
|
}
|
|
return self; //no path found
|
|
}
|
|
|
|
// /parent/(child).type/
|
|
// /parent/child.type/(name).type
|
|
inline auto prefix(string_view self) -> string {
|
|
const char* p = self.data() + self.size() - 1, *last = p;
|
|
for(int offset = self.size() - 1, suffix = -1; offset >= 0; offset--, p--) {
|
|
if(*p == '/' && p == last) continue;
|
|
if(*p == '/') return slice(self, offset + 1, suffix >= 0 ? suffix - offset - 1 : 0).trimRight("/");
|
|
if(*p == '.' && suffix == -1) { suffix = offset; continue; }
|
|
if(offset == 0) return slice(self, offset, suffix).trimRight("/");
|
|
}
|
|
return ""; //no prefix found
|
|
}
|
|
|
|
// /parent/child(.type)/
|
|
// /parent/child.type/name(.type)
|
|
inline auto suffix(string_view self) -> string {
|
|
const char* p = self.data() + self.size() - 1, *last = p;
|
|
for(int offset = self.size() - 1; offset >= 0; offset--, p--) {
|
|
if(*p == '/' && p == last) continue;
|
|
if(*p == '/') break;
|
|
if(*p == '.') return slice(self, offset).trimRight("/");
|
|
}
|
|
return ""; //no suffix found
|
|
}
|
|
|
|
}}
|