mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Fetch file size and last modified data when enumerating remote files
This commit is contained in:
@@ -38,6 +38,8 @@ struct DirectoryFile
|
||||
{
|
||||
rdctype::str filename;
|
||||
uint32_t flags;
|
||||
uint32_t lastmod;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
struct ResourceFormat
|
||||
|
||||
@@ -49,6 +49,8 @@ void Serialiser::Serialise(const char *name, DirectoryFile &el)
|
||||
|
||||
Serialise("filename", el.filename);
|
||||
Serialise("flags", el.flags);
|
||||
Serialise("lastmod", el.lastmod);
|
||||
Serialise("size", el.size);
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -290,6 +292,8 @@ static void ActiveRemoteClientThread(void *data)
|
||||
{
|
||||
DirectoryFile df;
|
||||
df.filename = files[i].filename;
|
||||
df.lastmod = files[i].lastmod;
|
||||
df.size = files[i].size;
|
||||
df.flags = files[i].flags;
|
||||
sendSer.Serialise("", df);
|
||||
}
|
||||
@@ -844,6 +848,8 @@ public:
|
||||
{
|
||||
DirectoryFile package;
|
||||
package.filename = trim(tokens[1]);
|
||||
package.size = 0;
|
||||
package.lastmod = 0;
|
||||
package.flags = eFileProp_Executable;
|
||||
packages.push_back(package);
|
||||
}
|
||||
|
||||
@@ -286,9 +286,11 @@ enum
|
||||
struct FoundFile
|
||||
{
|
||||
FoundFile() : flags(0) {}
|
||||
FoundFile(string fn, uint32_t f) : filename(fn), flags(f) {}
|
||||
FoundFile(string fn, uint32_t f) : filename(fn), flags(f), lastmod(0), size(0) {}
|
||||
string filename;
|
||||
uint32_t flags;
|
||||
uint32_t lastmod;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
vector<FoundFile> GetFilesInDirectory(const char *path);
|
||||
|
||||
@@ -305,7 +305,12 @@ vector<FoundFile> GetFilesInDirectory(const char *path)
|
||||
if(ent->d_name[0] == '.')
|
||||
flags |= eFileProp_Hidden;
|
||||
|
||||
ret.push_back(FoundFile(ent->d_name, flags));
|
||||
FoundFile f(ent->d_name, flags);
|
||||
|
||||
f.lastmod = (uint32_t)st.st_mtime;
|
||||
f.size = (uint64_t)st.st_size;
|
||||
|
||||
ret.push_back(f);
|
||||
}
|
||||
|
||||
// don't care if we hit an error or enumerated all files, just finish
|
||||
|
||||
@@ -432,7 +432,20 @@ vector<FoundFile> GetFilesInDirectory(const char *path)
|
||||
flags |= eFileProp_Executable;
|
||||
}
|
||||
|
||||
ret.push_back(FoundFile(StringFormat::Wide2UTF8(findData.cFileName), flags));
|
||||
FoundFile f(StringFormat::Wide2UTF8(findData.cFileName), flags);
|
||||
|
||||
uint64_t nanosecondsSinceWindowsEpoch = uint64_t(findData.ftLastWriteTime.dwHighDateTime) << 8 |
|
||||
uint64_t(findData.ftLastWriteTime.dwLowDateTime);
|
||||
|
||||
uint64_t secondsSinceWindowsEpoch = nanosecondsSinceWindowsEpoch / 10000000;
|
||||
|
||||
// this constant is the number of seconds between Jan 1 1601 and Jan 1 1970
|
||||
uint64_t secondsSinceUnixEpoch = secondsSinceWindowsEpoch - 11644473600;
|
||||
|
||||
f.lastmod = uint32_t(secondsSinceUnixEpoch);
|
||||
f.size = uint64_t(findData.nFileSizeHigh) << 8 | uint64_t(findData.nFileSizeLow);
|
||||
|
||||
ret.push_back(f);
|
||||
}
|
||||
} while(FindNextFile(find, &findData) != FALSE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user