mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Fix the sys::Path::getSuffix() implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52288 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1662183a83
commit
fc19988bcb
@ -185,11 +185,6 @@ bool Path::hasMagicNumber(const std::string &Magic) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string
|
||||
Path::getSuffix() const {
|
||||
return path.substr(path.rfind('.') + 1);
|
||||
}
|
||||
|
||||
static void getPathList(const char*path, std::vector<Path>& Paths) {
|
||||
const char* at = path;
|
||||
const char* delim = strchr(at, PathSeparator);
|
||||
|
@ -303,6 +303,22 @@ Path::getBasename() const {
|
||||
return path.substr(slash, dot - slash);
|
||||
}
|
||||
|
||||
std::string
|
||||
Path::getSuffix() const {
|
||||
// Find the last slash
|
||||
std::string::size_type slash = path.rfind('/');
|
||||
if (slash == std::string::npos)
|
||||
slash = 0;
|
||||
else
|
||||
slash++;
|
||||
|
||||
std::string::size_type dot = path.rfind('.');
|
||||
if (dot == std::string::npos || dot < slash)
|
||||
return std::string()
|
||||
else
|
||||
return path.substr(dot + 1);
|
||||
}
|
||||
|
||||
bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
|
||||
assert(len < 1024 && "Request for magic string too long");
|
||||
char* buf = (char*) alloca(1 + len);
|
||||
|
@ -259,6 +259,22 @@ Path::getBasename() const {
|
||||
return path.substr(slash, dot - slash);
|
||||
}
|
||||
|
||||
std::string
|
||||
Path::getSuffix() const {
|
||||
// Find the last slash
|
||||
size_t slash = path.rfind('/');
|
||||
if (slash == std::string::npos)
|
||||
slash = 0;
|
||||
else
|
||||
slash++;
|
||||
|
||||
size_t dot = path.rfind('.');
|
||||
if (dot == std::string::npos || dot < slash)
|
||||
return std::string();
|
||||
else
|
||||
return path.substr(dot + 1);
|
||||
}
|
||||
|
||||
bool
|
||||
Path::exists() const {
|
||||
DWORD attr = GetFileAttributes(path.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user