MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / Stat

Function Stat

MonaBase/sources/FileSystem.cpp:140–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138
139
140static Int8 Stat(const char* path, size_t size, Status& status) {
141
142 bool isFolder;
143 if (size) {
144 char c(path[size-1]);
145 isFolder = (c=='/' || c=='\\');
146 } else
147 isFolder = true;
148
149 bool found;
150
151#if defined (_WIN32)
152 // windows doesn't accept blackslash in _wstat
153 wchar_t wFile[_MAX_PATH];
154 size = MultiByteToWideChar(CP_UTF8, 0, path, size, wFile, _MAX_PATH);
155 if (isFolder)
156 wFile[size++] = '.';
157 wFile[size] = 0;
158 found = _wstat(wFile, &status)==0;
159#else
160 found = ::stat(size ? path : ".", &status)==0;
161#endif
162 if (!found)
163 return 0;
164 return status.st_mode&S_IFDIR ? (isFolder ? 1 : -1) : (isFolder ? -1 : 1);
165}
166
167
168FileSystem::Attributes& FileSystem::GetAttributes(const char* path,size_t size, Attributes& attributes) {

Callers 6

FileSystem.cppFile · 0.85
GetSizeMethod · 0.85
ExistsMethod · 0.85
CreateDirectoryMethod · 0.85
DeleteMethod · 0.85
ListFilesMethod · 0.85

Calls 1

statClass · 0.85

Tested by

no test coverage detected