tgstation-server
The /tg/station 13 server suite
PosixPostWriteHandler.cs
Go to the documentation of this file.
1 using Mono.Unix;
2 using Mono.Unix.Native;
3 using System;
4 
5 namespace Tgstation.Server.Host.IO
6 {
11  {
13  public void HandleWrite(string filePath)
14  {
15  if (filePath == null)
16  throw new ArgumentNullException(nameof(filePath));
17 
18  //set executable bit every time, don't want people calling me when their uploaded "sl" binary doesn't work
19  if (Syscall.stat(filePath, out var stat) != 0)
20  throw new UnixIOException(Stdlib.GetLastError());
21 
22  if (stat.st_mode.HasFlag(FilePermissions.S_IXUSR))
23  return;
24 
25  if (Syscall.chmod(filePath, stat.st_mode | FilePermissions.S_IXUSR) != 0)
26  throw new UnixIOException(Stdlib.GetLastError());
27  }
28  }
29 }
void HandleWrite(string filePath)
For handling system specific necessities after a write
IPostWriteHandler for POSIX systems