Ejemplo n.º 1
0
 public static unsafe int NormalizePathAndReturnHash(byte[] pPath, byte[] normalizedPath)
 {
     if (IsMacOS)
     {
         fixed(byte *outBuffer = &normalizedPath[0])
         {
             return(Impl_Mac.NormalizePathAndReturnHash(pPath, outBuffer, normalizedPath.Length));
         }
     }
     else
     {
         return(Impl_Linux.NormalizePathAndReturnHash(pPath, normalizedPath));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the current memory pressure level of the VM
 /// </summary>
 /// <param name="level">A PressureLevel pointer to hold the current VM memory pressure level</param>
 public static int GetMemoryPressureLevel(ref PressureLevel level) => IsMacOS
     ? Impl_Mac.GetMemoryPressureLevel(ref level)
     : Impl_Linux.GetMemoryPressureLevel(ref level);
Ejemplo n.º 3
0
 /// <summary>
 /// Returns a process peak working set size in bytes
 /// </summary>
 /// <param name="pid">The process id to check</param>
 /// <param name="buffer">A long pointer to hold the process peak memory usage</param>
 public static int GetPeakWorkingSetSize(int pid, ref ulong buffer) => IsMacOS
     ? Impl_Mac.GetPeakWorkingSetSize(pid, ref buffer)
     : Impl_Linux.GetPeakWorkingSetSize(pid, ref buffer);
Ejemplo n.º 4
0
 /// <summary>
 /// Returns the current host memory usage information to the caller
 /// </summary>
 /// <param name="buffer">A RamUsageInfo struct pointer to hold memory statistics</param>
 public static int GetRamUsageInfo(ref RamUsageInfo buffer) => IsMacOS
     ? Impl_Mac.GetRamUsageInfo(ref buffer)
     : Impl_Linux.GetRamUsageInfo(ref buffer);
Ejemplo n.º 5
0
        #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

        /// <summary>
        /// Returns the current CPU load info accross all CPU cores to the caller
        /// </summary>
        /// <param name="buffer">A CpuLoadInfo struct to hold the timing inforamtion of the current host CPU</param>
        public static int GetCpuLoadInfo(ref CpuLoadInfo buffer) => IsMacOS
            ? Impl_Mac.GetCpuLoadInfo(ref buffer, Marshal.SizeOf(buffer))
            : Impl_Linux.GetCpuLoadInfo(ref buffer, Marshal.SizeOf(buffer));
Ejemplo n.º 6
0
 /// <summary>
 /// Opens a file at a specified path.
 /// </summary>
 public static SafeFileHandle Open(string pathname, OpenFlags flags, FilePermissions permission) => IsMacOS
     ? Impl_Mac.Open(pathname, flags, permission)
     : Impl_Linux.Open(pathname, flags, permission);
Ejemplo n.º 7
0
 /// <summary>
 /// Sets the file permissions flag for the entry at <paramref name="path"/>
 /// </summary>
 public static int SetFilePermissionsForFilePath(string path, FilePermissions permissions, bool followSymlink = true) => IsMacOS
     ? Impl_Mac.SetFilePermissionsForFilePath(path, permissions, followSymlink)
     : Impl_Linux.SetFilePermissionsForFilePath(path, permissions, followSymlink);
Ejemplo n.º 8
0
 /// <summary>
 /// Retrieves  the  value  of  the extended attribute identified by <paramref name="name"/> and associated
 /// with the given <paramref name="path"/> in the filesystem. If <paramref name="name"/> is a symlink,
 /// the attribute is retrieved from the link itself and not the file it refers to.
 /// </summary>
 public static unsafe long GetXattrNoFollow(string path, string name, ref long value) => IsMacOS
     ? Impl_Mac.getxattr(path, name, ref value, sizeof(long), 0, Impl_Mac.XATTR_NOFOLLOW)
     : Impl_Linux.lgetxattr(path, "user." + name, ref value, sizeof(long), 0);
Ejemplo n.º 9
0
 /// <summary>
 /// Sets the creation, modification, change and access time of a file specified at path
 /// </summary>
 /// <returns>Returns zero in case of success, otherwise error</returns>
 public static int SetTimeStampsForFilePath(string path, bool followSymlink, StatBuffer buffer) => IsMacOS
     ? Impl_Mac.SetTimeStampsForFilePath(path, followSymlink, buffer)
     : Impl_Linux.SetTimeStampsForFilePath(path, followSymlink, buffer);
Ejemplo n.º 10
0
 /// <summary>
 /// Read the value of a symbolic link specified by <paramref name="link"/>
 /// Returns number of bytes placed in buf, and -1 otherwise.
 /// </summary>
 public static long SafeReadLink(string link, StringBuilder buffer, long length) => IsMacOS
     ? Impl_Mac.SafeReadLink(link, buffer, length)
     : Impl_Linux.SafeReadLink(link, buffer, length);
Ejemplo n.º 11
0
 /// <summary>
 /// Returns the root mount for a given path or <c>null</c> in case of an error.
 /// </summary>
 /// <param name="path">Path name of any file or directory within the mounted file system</param>
 /// <returns>String containing the mount name</returns>
 public static string GetMountNameForPath(string path) => IsMacOS
     ? Impl_Mac.GetMountNameForPath(path)
     : Impl_Linux.GetMountNameForPath(path);
Ejemplo n.º 12
0
 /// <summary>
 /// Gets the name (e.g., "EXT4", "APFS", etc.) of the filesystem on which file <paramref name="fd" /> resides.
 /// </summary>
 /// <returns>
 /// There result (filesystem name) is stored in the <paramref name="fsTypeName"/> buffer.
 /// The return value is the length of that buffer or -1 upon error.
 /// </returns>
 public static int GetFileSystemType(SafeFileHandle fd, StringBuilder fsTypeName, long bufferSize) => IsMacOS
     ? Impl_Mac.GetFileSystemType(fd, fsTypeName, bufferSize)
     : Impl_Linux.GetFileSystemType(fd, fsTypeName, bufferSize);
Ejemplo n.º 13
0
 /// <summary>
 /// Same as <see cref="StatFile" /> except that the target file is given as a file descriptor (<paramref name="fd" />).
 /// </summary>
 public static int StatFileDescriptor(SafeFileHandle fd, ref StatBuffer statBuf) => IsMacOS
     ? Impl_Mac.StatFileDescriptor(fd, ref statBuf)
     : Impl_Linux.StatFileDescriptor(fd, ref statBuf);
Ejemplo n.º 14
0
 /// <summary>
 /// Implements the standard unix 'stat' command.
 /// </summary>
 /// <returns>
 /// Upon successful completion a value of 0 is returned and the result is stored in <paramref name="statBuf"/>;
 /// otherwise, a value of -1 is returned and <see cref="Marshal.GetLastWin32Error"/> is set to indicate the error.
 /// </returns>
 public static int StatFile(string path, bool followSymlink, ref StatBuffer statBuf) => IsMacOS
     ? Impl_Mac.StatFile(path, followSymlink, ref statBuf)
     : Impl_Linux.StatFile(path, followSymlink, ref statBuf);
Ejemplo n.º 15
0
 /// <summary>
 /// Populates a process resource usage information buffer with memory usage information only.
 /// </summary>
 /// <param name="pid">The process id to check</param>
 /// <param name="buffer">A ProcessResourceUsage struct to hold the memory usage information</param>
 /// <param name="includeChildProcesses">Whether the result should include the usage numbers of all the child processes</param>
 public static int GetProcessMemoryUsage(int pid, ref ProcessResourceUsage buffer, bool includeChildProcesses) => IsMacOS
     ? Impl_Mac.GetProcessResourceUsageSnapshot(pid, ref buffer, Marshal.SizeOf(buffer), includeChildProcesses)
     : Impl_Linux.GetProcessMemoryUsageSnapshot(pid, ref buffer, Marshal.SizeOf(buffer), includeChildProcesses);