Beispiel #1
0
                public void SetACL(IAbsolutePath location, string user = null,
                                   FileSystemRights rights             = FileSystemRights.FullControl)
                {
                    if (user == null)
                    {
                        user = GetCurrentUserSDDL();
                    }

                    var path = location.ToString();

                    if (Directory.Exists(path))
                    {
                        var dp = path.ToAbsoluteDirectoryPath();
                        try {
                            SetDirectoryACL(dp, user, rights);
                        } catch (InvalidOperationException) {
                            FixDirectoryACL(dp);
                            SetDirectoryACL(dp, user, rights);
                        }
                    }
                    else if (File.Exists(path))
                    {
                        var fp = path.ToAbsoluteFilePath();
                        try {
                            SetFileACL(fp, user, rights);
                        } catch (InvalidOperationException) {
                            FixFileACL(fp);
                            SetFileACL(fp, user, rights);
                        }
                    }
                    else
                    {
                        throw new Exception("Path does not exist");
                    }
                }
            internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string relativePath, out string failureMessage)
            {
                //Argument.IsNotNull(nameof(pathFrom), pathFrom);
                //Argument.IsNotNull(nameof(pathTo), pathTo);

                if (!pathFrom.OnSameVolumeThan(pathTo))
                {
                    failureMessage = @"Cannot compute relative path from 2 paths that are not on the same volume 
   PathFrom = """ + pathFrom + @"""
   PathTo   = """ + pathTo + @"""";

                    relativePath = null;

                    return(false);
                }

                // Only work with Directory
                if (pathTo.IsFilePath)
                {
                    pathTo = pathTo.ParentDirectoryPath;
                }

                relativePath   = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString());
                failureMessage = null;

                return(true);
            }
         //
         //  Relative/absolute computation
         //

         internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string pathResult, out string failurereason) {
            Debug.Assert(pathFrom != null);
            Debug.Assert(pathTo != null);

            if (!pathFrom.OnSameVolumeThan(pathTo)) {
               failurereason = @"Cannot compute relative path from 2 paths that are not on the same volume 
   PathFrom = """ + pathFrom.ToString() + @"""
   PathTo   = """ + pathTo.ToString() + @"""";
               pathResult = null;
               return false;
            }
            // Only work with Directory 
            if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; }
            pathResult = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString());
            failurereason = null;
            return true;
         }
            //
            //  Relative/absolute computation
            //

            internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string pathResult, out string failurereason)
            {
                Debug.Assert(pathFrom != null);
                Debug.Assert(pathTo != null);

                if (!pathFrom.OnSameVolumeThan(pathTo))
                {
                    failurereason = @"Cannot compute relative path from 2 paths that are not on the same volume 
   PathFrom = """ + pathFrom.ToString() + @"""
   PathTo   = """ + pathTo.ToString() + @"""";
                    pathResult    = null;
                    return(false);
                }
                // Only work with Directory
                if (pathTo.IsFilePath)
                {
                    pathTo = pathTo.ParentDirectoryPath;
                }
                pathResult    = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString());
                failurereason = null;
                return(true);
            }
Beispiel #5
0
 public bool ComparePathsOsCaseSensitive(IAbsolutePath path1, IAbsolutePath path2) {
     return GetFullCleanPath(path1.ToString()).Equals(GetFullCleanPath(path2.ToString()));
 }
Beispiel #6
0
 public void RunMakePboWithParameters(IAbsoluteDirectoryPath input, IAbsolutePath output,
                                      params string[] parameters)
 {
     RunMakePbo(BuildParameters(input.ToString(), output.ToString(), parameters));
 }
Beispiel #7
0
 static void CreateDirectoryAndSetACLWithUpdater(IAbsolutePath location, string user,
                                                 FileSystemRights rights)
 => Generic.RunUpdater(UpdaterCommands.SetAcl, location.ToString(), "--user="******"--rights=" + rights,
                       "--createDirectory");
			internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string relativePath, out string failureMessage)
			{
				//Argument.IsNotNull(nameof(pathFrom), pathFrom);
				//Argument.IsNotNull(nameof(pathTo), pathTo);

				if (!pathFrom.OnSameVolumeThan(pathTo))
				{
					failureMessage = @"Cannot compute relative path from 2 paths that are not on the same volume 
   PathFrom = """ + pathFrom + @"""
   PathTo   = """ + pathTo + @"""";

					relativePath = null;

					return false;
				}

				// Only work with Directory 
				if (pathTo.IsFilePath)
				{
					pathTo = pathTo.ParentDirectoryPath;
				}

				relativePath = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString());
				failureMessage = null;

				return true;
			}
Beispiel #9
0
 public bool ComparePathsOsCaseSensitive(IAbsolutePath path1, IAbsolutePath path2)
 => GetFullCleanPath(path1.ToString()).Equals(GetFullCleanPath(path2.ToString()));
Beispiel #10
0
 public void RunMakePboWithParameters(IAbsoluteDirectoryPath input, IAbsolutePath output,
     params string[] parameters) {
     RunMakePbo(BuildParameters(input.ToString(), output.ToString(), parameters));
 }