forked from OctaForge/libostd
don't alloc path twice
parent
b02966fb9d
commit
8b7fc0f791
|
@ -130,14 +130,14 @@ struct FileInfo {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init_from_str(ConstCharRange path) {
|
void init_from_str(ConstCharRange path) {
|
||||||
|
p_path = path;
|
||||||
#ifdef OSTD_PLATFORM_WIN32
|
#ifdef OSTD_PLATFORM_WIN32
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||||
if (!GetFileAttributesEx(String(path).data(), GetFileExInfoStandard,
|
if (!GetFileAttributesEx(p_path.data(), GetFileExInfoStandard, &attr) ||
|
||||||
&attr) ||
|
|
||||||
attr.dwFileAttributes == INVALID_FILE_ATTRIBUTES)
|
attr.dwFileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(String(path).data(), &st) < 0)
|
if (stat(p_path.data(), &st) < 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
p_slash = p_dot = npos;
|
p_slash = p_dot = npos;
|
||||||
|
@ -146,7 +146,6 @@ private:
|
||||||
p_atime = p_mtime = p_ctime = 0;
|
p_atime = p_mtime = p_ctime = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p_path = path;
|
|
||||||
ConstCharRange r = p_path.iter();
|
ConstCharRange r = p_path.iter();
|
||||||
|
|
||||||
ConstCharRange found = find_last(r, PathSeparator);
|
ConstCharRange found = find_last(r, PathSeparator);
|
||||||
|
|
Loading…
Reference in New Issue