MCPcopy Create free account
hub / github.com/Singular/Singular / FileStat

Function FileStat

ppcc/adlib/os.cc:218–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218bool FileStat(FileInfo &info, const char *path, bool follow_links) {
219 struct stat st;
220 if (follow_links) {
221 if (stat(path, &st) < 0)
222 return false;
223 } else {
224 if (lstat(path, &st) < 0)
225 return false;
226 }
227 memset(&info, 0, sizeof(info));
228 if (S_ISDIR(st.st_mode)) {
229 info.is_dir = true;
230 } else if (S_ISREG(st.st_mode)) {
231 info.is_file = true;
232 } else if (S_ISLNK(st.st_mode)) {
233 info.is_link = true;
234 } else {
235 info.is_other = true;
236 }
237 info.atime = st.st_atime;
238 info.mtime = st.st_mtime;
239 info.ctime = st.st_ctime;
240 info.size = st.st_size;
241 return true;
242}
243
244bool FileStat(FileInfo &info, Str *path, bool follow_links) {
245 return FileStat(info, path->c_str(), follow_links);

Callers 6

MainFunction · 0.85
WalkDirFunction · 0.85
ListFileTreeFunction · 0.85
MakeDirRecFunction · 0.85
ProgramPathFunction · 0.85
TestOutputExecutableFunction · 0.85

Calls 2

c_strMethod · 0.80
statClass · 0.70

Tested by 2

MainFunction · 0.68
TestOutputExecutableFunction · 0.68