public static bool TryStatFileAndUpdateIndex(ITracer tracer, string path, MemoryMappedViewAccessor indexView, long offset) { try { LinuxNative.StatBuffer st = LinuxFileSystem.StatFile(path); Index.IndexEntry indexEntry = new Index.IndexEntry(indexView, offset); indexEntry.MtimeSeconds = (uint)st.MTimespec.Sec; indexEntry.MtimeNanosecondFraction = (uint)st.MTimespec.Nsec; indexEntry.CtimeSeconds = (uint)st.CTimespec.Sec; indexEntry.CtimeNanosecondFraction = (uint)st.CTimespec.Nsec; indexEntry.Size = (uint)st.Size; indexEntry.Dev = (uint)st.Dev; indexEntry.Ino = (uint)st.Ino; indexEntry.Uid = st.UID; indexEntry.Gid = st.GID; return(true); } catch (Win32Exception e) { EventMetadata metadata = new EventMetadata(); metadata.Add("path", path); metadata.Add("exception", e.ToString()); tracer.RelatedError(metadata, "Error stat-ing file."); return(false); } }
public static bool TryStatFileAndUpdateIndex(ITracer tracer, string path, MemoryMappedViewAccessor indexView, long offset) { try { FileInfo file = new FileInfo(path); if (file.Exists) { Index.IndexEntry indexEntry = new Index.IndexEntry(indexView, offset); indexEntry.Mtime = file.LastWriteTimeUtc; indexEntry.Ctime = file.CreationTimeUtc; indexEntry.Size = (uint)file.Length; return(true); } } catch (System.Security.SecurityException) { // Skip these. } catch (System.UnauthorizedAccessException) { // Skip these. } return(false); }