don't alloc path twice

master
Daniel Kolesa 2016-07-07 17:06:57 +01:00
parent b02966fb9d
commit 8b7fc0f791
1 changed files with 3 additions and 4 deletions

View File

@ -130,14 +130,14 @@ struct FileInfo {
private:
void init_from_str(ConstCharRange path) {
p_path = path;
#ifdef OSTD_PLATFORM_WIN32
WIN32_FILE_ATTRIBUTE_DATA attr;
if (!GetFileAttributesEx(String(path).data(), GetFileExInfoStandard,
&attr) ||
if (!GetFileAttributesEx(p_path.data(), GetFileExInfoStandard, &attr) ||
attr.dwFileAttributes == INVALID_FILE_ATTRIBUTES)
#else
struct stat st;
if (stat(String(path).data(), &st) < 0)
if (stat(p_path.data(), &st) < 0)
#endif
{
p_slash = p_dot = npos;
@ -146,7 +146,6 @@ private:
p_atime = p_mtime = p_ctime = 0;
return;
}
p_path = path;
ConstCharRange r = p_path.iter();
ConstCharRange found = find_last(r, PathSeparator);