You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

65 lines
1.7 KiB

  1. using Alphaleonis.Win32.Filesystem;
  2. using System.Management.Automation;
  3. namespace NTFSSecurity
  4. {
  5. public class FileSystemCodeMembers
  6. {
  7. public static string Mode(PSObject obj)
  8. {
  9. if (obj == null)
  10. {
  11. return string.Empty;
  12. }
  13. FileSystemInfo item = (FileSystemInfo)obj.BaseObject;
  14. if (item == null)
  15. {
  16. return string.Empty;
  17. }
  18. string text = "";
  19. if ((item.Attributes & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
  20. {
  21. text += "d";
  22. }
  23. else
  24. {
  25. text += "-";
  26. }
  27. if ((item.Attributes & System.IO.FileAttributes.Archive) == System.IO.FileAttributes.Archive)
  28. {
  29. text += "a";
  30. }
  31. else
  32. {
  33. text += "-";
  34. }
  35. if ((item.Attributes & System.IO.FileAttributes.ReadOnly) == System.IO.FileAttributes.ReadOnly)
  36. {
  37. text += "r";
  38. }
  39. else
  40. {
  41. text += "-";
  42. }
  43. if ((item.Attributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden)
  44. {
  45. text += "h";
  46. }
  47. else
  48. {
  49. text += "-";
  50. }
  51. if ((item.Attributes & System.IO.FileAttributes.System) == System.IO.FileAttributes.System)
  52. {
  53. text += "s";
  54. }
  55. else
  56. {
  57. text += "-";
  58. }
  59. return text;
  60. }
  61. }
  62. }