MCPcopy Create free account
hub / github.com/ZDoom/Raze / GetFileInfo

Function GetFileInfo

source/common/utility/cmdlib.cpp:221–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219//==========================================================================
220
221bool GetFileInfo(const char* pathname, size_t *size, time_t *time)
222{
223 if (pathname == NULL || *pathname == 0)
224 return false;
225
226#ifndef _WIN32
227 struct stat info;
228 bool res = stat(pathname, &info) == 0;
229#else
230 // Windows must use the wide version of stat to preserve non-standard paths.
231 auto wstr = WideString(pathname);
232 struct _stat64 info;
233 bool res = _wstat64(wstr.c_str(), &info) == 0;
234#endif
235 if (!res || (info.st_mode & S_IFDIR)) return false;
236 if (size) *size = (size_t)info.st_size;
237 if (time) *time = info.st_mtime;
238 return res;
239}
240
241//==========================================================================
242//

Callers 1

Calls 3

WideStringFunction · 0.85
c_strMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected