Пример #1
0
 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);
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public override bool IsSocket(string fileName)
 {
     NativeStat.StatBuffer statBuffer = this.StatFile(fileName);
     return(NativeStat.IsSock(statBuffer.Mode));
 }
Пример #5
0
 public bool IsExecutable(string fileName)
 {
     NativeStat.StatBuffer statBuffer = this.StatFile(fileName);
     return(NativeStat.IsExecutable(statBuffer.Mode));
 }