MCPcopy Create free account
hub / github.com/Kitware/CMake / FileLength

Method FileLength

Source/kwsys/SystemTools.cxx:2697–2718  ·  view source on GitHub ↗

return size of file; also returns zero if no file exists

Source from the content-addressed store, hash-verified

2695
2696// return size of file; also returns zero if no file exists
2697unsigned long SystemTools::FileLength(std::string const& filename)
2698{
2699 unsigned long length = 0;
2700#ifdef _WIN32
2701 WIN32_FILE_ATTRIBUTE_DATA fs;
2702 if (GetFileAttributesExW(Encoding::ToWindowsExtendedPath(filename).c_str(),
2703 GetFileExInfoStandard, &fs) != 0) {
2704 /* To support the full 64-bit file size, use fs.nFileSizeHigh
2705 * and fs.nFileSizeLow to construct the 64 bit size
2706
2707 length = ((__int64)fs.nFileSizeHigh << 32) + fs.nFileSizeLow;
2708 */
2709 length = static_cast<unsigned long>(fs.nFileSizeLow);
2710 }
2711#else
2712 struct stat fs;
2713 if (stat(filename.c_str(), &fs) == 0) {
2714 length = static_cast<unsigned long>(fs.st_size);
2715 }
2716#endif
2717 return length;
2718}
2719
2720int SystemTools::Strucmp(char const* l, char const* r)
2721{

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected