3using Microsoft.Extensions.Logging;
17 readonly ILogger<PosixPostWriteHandler>
logger;
25 this.logger =
logger ??
throw new ArgumentNullException(nameof(
logger));
31 ArgumentNullException.ThrowIfNull(sourceFilePath);
33 if (Syscall.stat(sourceFilePath, out var stat) != 0)
34 throw new UnixIOException(Stdlib.GetLastError());
36 return stat.st_mode.HasFlag(FilePermissions.S_IXUSR);
42 ArgumentNullException.ThrowIfNull(filePath);
45 if (Syscall.stat(filePath, out var stat) != 0)
46 throw new UnixIOException(Stdlib.GetLastError());
48 if (stat.st_mode.HasFlag(FilePermissions.S_IXUSR))
50 logger.LogTrace(
"{0} already +x", filePath);
54 logger.LogTrace(
"Setting +x on {0}", filePath);
55 if (Syscall.chmod(filePath, stat.st_mode | FilePermissions.S_IXUSR) != 0)
56 throw new UnixIOException(Stdlib.GetLastError());
IPostWriteHandler for POSIX systems.
PosixPostWriteHandler(ILogger< PosixPostWriteHandler > logger)
Initializes a new instance of the PosixPostWriteHandler class.
void HandleWrite(string filePath)
For handling system specific necessities after a write.
readonly ILogger< PosixPostWriteHandler > logger
The ILogger<TCategoryName> for the PosixPostWriteHandler.
bool NeedsPostWrite(string sourceFilePath)
Check if a given sourceFilePath will need HandleWrite(string) called on a copy of it....
Handles changing file modes/permissions after writing.