public static bool TryStatFileAndUpdateIndex(ITracer tracer, string path, MemoryMappedViewAccessor indexView, long offset) { try { NativeStat.StatBuffer st = 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); } }
private NativeStat.StatBuffer StatFile(string fileName) { NativeStat.StatBuffer statBuffer = new NativeStat.StatBuffer(); if (NativeStat.Stat(fileName, out statBuffer) != 0) { NativeMethods.ThrowLastWin32Exception($"Failed to stat {fileName}"); } return(statBuffer); }
private static NativeStat.StatBuffer StatFile(string fileName) { NativeStat.StatBuffer statBuffer = new NativeStat.StatBuffer(); if (NativeStat.Stat(fileName, out statBuffer) != 0) { throw new Win32Exception(Marshal.GetLastWin32Error(), $"Failed to stat {fileName}"); } return(statBuffer); }
public override bool IsSocket(string fileName) { NativeStat.StatBuffer statBuffer = this.StatFile(fileName); return(NativeStat.IsSock(statBuffer.Mode)); }
public bool IsExecutable(string fileName) { NativeStat.StatBuffer statBuffer = this.StatFile(fileName); return(NativeStat.IsExecutable(statBuffer.Mode)); }