示例#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");
                    }
                }
示例#2
0
        public override void Execute(IAbsolutePath path, AbsoluteFilePath project, IEnumerable <string> arguments)
        {
            var file = path as AbsoluteFilePath;

            if (file == null)
            {
                throw new ImportFailed("'" + path + "' does not appear to be a file");
            }

            var outputDir = project.ContainingDirectory.Combine(SketchImportUtils.OutputDirName);

            try
            {
                Directory.CreateDirectory(outputDir.NativePath);
            }
            catch (Exception e)
            {
                _reportLogger.Error("Sketch importer error: " + e.Message);
            }

            if (SketchImportUtils.IsSketchFile(file))
            {
                TryConvert(new[] { file.NativePath }, outputDir.NativePath);
            }
            else if (SketchImportUtils.IsSketchFilesFile(file))
            {
                // load sketch file paths from the json-file
                var sketchFiles = SketchImportUtils.MakeAbsolute(
                    SketchImportUtils.SketchFilePaths(SketchImportUtils.SketchListFilePath(project), _reportLogger),
                    project.ContainingDirectory).Select(f => f.NativePath).ToArray();

                TryConvert(sketchFiles, outputDir.NativePath);
            }
        }
示例#3
0
 private void LaunchFuseOpen(string[] args, IAbsolutePath projectPath = null)
 {
     if (Platform.OperatingSystem == OS.Windows)
     {
         var actualArgs = new List <string> {
             "--override-fuse-exe=\"" + _fuse.FuseExe + "\""
         };
         if (projectPath != null)
         {
             actualArgs.Add(projectPath.NativePath);
         }
         actualArgs.AddRange(args);
         Designer.Program.Main(actualArgs.ToArray());
     }
     else if (Platform.OperatingSystem == OS.Mac)
     {
         var startInfo = new ProcessStartInfo()
         {
             Arguments = args.Select(a => "\"" + a + "\"").Join(" "),
         };
         if (projectPath == null)
         {
             _fuse.Designer.Start(startInfo);
         }
         else
         {
             _fuse.Designer.Open(_fileSystem.ResolveAbsolutePath(projectPath.NativePath), startInfo);
         }
     }
 }
            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);
            }
示例#5
0
 public static void AssertExists(Shell shell, IAbsolutePath mainView)
 {
     if (!shell.Exists(mainView))
     {
         throw new TestFailure("Expected to see '" + mainView + "', but it doesn't exist.");
     }
 }
			public override EnvironmentVariableResolvingStatus TryResolve(out IAbsolutePath resolvedPath)
			{
				IAbsoluteDirectoryPath pathDirectoryResolved;
				var resolvingStatus = TryResolve(out pathDirectoryResolved);
				resolvedPath = pathDirectoryResolved;
				return resolvingStatus;
			}
			public override bool TryResolve(out IAbsolutePath resolvedPath, out string failureMessage)
			{
				IAbsoluteDirectoryPath pathDirectoryResolved;
				var b = TryResolve(out pathDirectoryResolved, out failureMessage);
				resolvedPath = pathDirectoryResolved;
				return b;
			}
示例#8
0
        protected static ProcessResult RunProcess(IAbsolutePath path, string args, TimeSpan timeout, AbsoluteDirectoryPath workingDir = null)
        {
            var stdout = new StringBuilder();
            var stderr = new StringBuilder();
            var p      = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = path.NativePath,
                    Arguments              = args,
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true
                }
            };

            if (workingDir != null)
            {
                p.StartInfo.WorkingDirectory = workingDir.NativePath;
            }
            p.OutputDataReceived += (s, e) => stdout.Append(e.Data + "\n");
            p.ErrorDataReceived  += (s, e) => stderr.Append(e.Data + "\n");
            p.Start();
            p.BeginOutputReadLine();
            p.BeginErrorReadLine();
            var exited = p.WaitForExit((int)timeout.TotalMilliseconds);

            if (!exited)
            {
                throw new Exception("'" + p.StartInfo.FileName + "' failed to exit");
            }
            return(new ProcessResult(p.ExitCode, stdout.ToString(), stderr.ToString()));
        }
            public override EnvironmentVariableResolvingStatus TryResolve(out IAbsolutePath resolvedPath)
            {
                IAbsoluteFilePath pathFileResolved;
                var resolvingStatus = TryResolve(out pathFileResolved);

                resolvedPath = pathFileResolved;
                return(resolvingStatus);
            }
        public void Test_IsNotNullAndExists()
        {
            IAbsolutePath path = null;

            Assert.IsFalse(path.IsNotNullAndExists());
            path = @"L:\NonExistingDir".ToAbsoluteDirectoryPath();
            Assert.IsFalse(path.IsNotNullAndExists());
        }
            public override bool TryResolve(out IAbsolutePath resolvedPath, out string failureMessage)
            {
                IAbsoluteFilePath pathFileResolved;
                var b = TryResolve(out pathFileResolved, out failureMessage);

                resolvedPath = pathFileResolved;
                return(b);
            }
            public override bool TryResolve(out IAbsolutePath pathResolved, out string failureReason)
            {
                IAbsoluteFilePath pathFileResolved;
                var b = this.TryResolve(out pathFileResolved, out failureReason);

                pathResolved = pathFileResolved;
                return(b);
            }
示例#13
0
            public override EnvVarPathResolvingStatus TryResolve(out IAbsolutePath resolvedPath)
            {
                IAbsoluteDirectoryPath pathDirectoryResolved;
                var resolvingStatus = TryResolve(out pathDirectoryResolved);

                resolvedPath = pathDirectoryResolved;
                return(resolvingStatus);
            }
            public override EnvVarPathResolvingStatus TryResolve(out IAbsolutePath pathResolved)
            {
                IAbsoluteFilePath pathFileResolved;
                var resolvingStatus = this.TryResolve(out pathFileResolved);

                pathResolved = pathFileResolved;
                return(resolvingStatus);
            }
示例#15
0
        public Process Open(IAbsolutePath fileName, Optional <ProcessStartInfo> startInfo)
        {
            var newStartInfo = startInfo.Or(new ProcessStartInfo());

            newStartInfo.Arguments = "\"" + fileName + "\" " + newStartInfo.Arguments;

            return(Start(newStartInfo));
        }
示例#16
0
        public Process Open(IAbsolutePath fileName, Optional <ProcessStartInfo> startInfo)
        {
            var newStartInfo = startInfo.Or(new ProcessStartInfo());

            newStartInfo.FileName  = "open";
            newStartInfo.Arguments = "-a \"" + _appBundle.NativePath + "\" " + '"' + fileName + "\" --args " + newStartInfo.Arguments;

            return(Process.Start(newStartInfo));
        }
            public override EnvironmentVariableResolvingStatus TryResolve(out IAbsolutePath resolvedPath)
            {
                IAbsoluteDirectoryPath directoryPath;

                var resolvingStatus = TryResolve(out directoryPath);

                resolvedPath = directoryPath;

                return(resolvingStatus);
            }
            public override bool TryResolve(out IAbsolutePath resolvedPath, out string failureMessage)
            {
                IAbsoluteDirectoryPath directoryPath;

                var result = TryResolve(out directoryPath, out failureMessage);

                resolvedPath = directoryPath;

                return(result);
            }
示例#19
0
        public static async Task Remove(IAbsolutePath path)
        {
            var list = await All.FirstAsync();

            var newList =
                list.RemoveAll(item => item.ProjectPath.Equals(path))
                .Distinct(new ProjectDataPathComparer());

            UserSetting.Write(Optional.Some(newList), save: true);
        }
            public override bool TryResolve(out IAbsolutePath resolvedPath, out string failureMessage)
            {
                IAbsoluteFilePath filePath;

                var result = TryResolve(out filePath, out failureMessage);

                resolvedPath = filePath;

                return(result);
            }
示例#21
0
        bool NotSpaceInPath(IAbsolutePath path, IProgress <InstallerEvent> progress)
        {
            if (path.NativePath.Contains(" "))
            {
                progress.Report(
                    new InstallerMessage("The native build system for Android doesn't support having Android SDK in a path that contains space(s)."));
                return(false);
            }

            return(true);
        }
示例#22
0
 public void SetACLHandleInvalidOperation(IAbsolutePath location, string user = null,
                                          FileSystemRights rights             = FileSystemRights.FullControl)
 {
     try {
         SetACL(location, user, rights);
     } catch (InvalidOperationException ex) {
         // e.g Method failed with unexpected error code 1.
         this.Logger()
         .FormattedWarnException(ex,
                                 "Invalid operation while processing ACL, probably network drive");
     }
 }
示例#23
0
 public static bool IsInvalidWithMessage(IProgress <InstallerEvent> progress, IAbsolutePath path)
 {
     if (IsInvalid(path))
     {
         progress.Report(new InstallerMessage("'" + path.NativePath + "'" + " is rooted in '/usr/share', which is disallowed in El Capitan (10.11) and later versions of OS X."));
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#24
0
        public static IAbsolutePath GetRoot(this IAbsolutePath self)
        {
            while (true)
            {
                if (self.ContainingDirectory == null)
                {
                    return(self);
                }

                self = self.ContainingDirectory;
            }
        }
示例#25
0
        public override bool CanExecute(IAbsolutePath path, AbsoluteFilePath project)
        {
            var file = path as AbsoluteFilePath;

            if (file == null)
            {
                return(false);
            }

            return(_fileSystem.Exists(file) && _fileSystem.Exists(project) &&
                   (SketchImportUtils.IsSketchFile(file) || file.Name.HasExtension(SketchImportUtils.SketchFilesExtension)));
        }
示例#26
0
 public static Guid IdFor(IAbsolutePath projectPath)
 {
     using (var md5Hash = MD5.Create())
     {
         var data     = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(projectPath.NativePath));
         var sBuilder = new StringBuilder();
         foreach (var t in data)
         {
             sBuilder.Append(t.ToString("x2"));
         }
         return(new Guid(sBuilder.ToString()));
     }
 }
示例#27
0
        /// <exception cref="IOException" />
        /// <exception cref="UnauthorizedAccessException" />
        IEnumerable <AbsoluteFilePath> GetProjects(IAbsolutePath directoryOrFileInProject)
        {
            if (!_fileSystem.Exists(directoryOrFileInProject))
            {
                throw new FileNotFoundException(
                          "Could not find file or directory `" + directoryOrFileInProject.NativePath + "`",
                          directoryOrFileInProject.NativePath);
            }

            return(directoryOrFileInProject.MatchWith(
                       (AbsoluteFilePath file) => GetProjectsContaining(file),
                       (AbsoluteDirectoryPath dir) => GetProjectsInOrContaining(dir)));
        }
示例#28
0
 /// <exception cref="ProjectNotFound" />
 public AbsoluteFilePath GetProject(IAbsolutePath directoryOrFileInProject)
 {
     try
     {
         return(GetProjects(directoryOrFileInProject).FirstOrNone().OrThrow(new ProjectNotFound()));
     }
     catch (IOException e)
     {
         throw new ProjectNotFound(e);
     }
     catch (UnauthorizedAccessException e)
     {
         throw new ProjectNotFound(e);
     }
 }
示例#29
0
            public bool OnSameVolumeThan(IAbsolutePath otherAbsolutePath)
            {
                Argument.IsNotNull(nameof(otherAbsolutePath), otherAbsolutePath);

                if (Type != otherAbsolutePath.Type)
                {
                    return(false);
                }

                if (Type == AbsolutePathType.DriveLetter)
                {
                    return(DriveLetter.Equals(otherAbsolutePath.DriveLetter));
                }

                return(string.Compare(UNCServer, otherAbsolutePath.UNCServer, StringComparison.OrdinalIgnoreCase) == 0 &&
                       string.Compare(UNCShare, otherAbsolutePath.UNCShare, StringComparison.OrdinalIgnoreCase) == 0);
            }
         //
         //  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;
         }
示例#31
0
 public void SetACLWithFallbackAndRetry(IAbsolutePath location, string user = null,
                                        FileSystemRights rights             = FileSystemRights.FullControl)
 {
     if (user == null)
     {
         user = GetCurrentUserSDDL();
     }
     AddIORetryDialog(() => {
         try {
             SetACLHandleInvalidOperation(location, user, rights);
         } catch (UnauthorizedAccessException ex) {
             this.Logger()
             .FormattedWarnException(ex,
                                     "Exception during setACL, trying through updater if not elevated");
             SetACLWithUpdater(location, user, rights);
         }
     });
 }
 public bool OnSameVolumeThan(IAbsolutePath pathAbsoluteOther) {
    Debug.Assert(pathAbsoluteOther != null); // Enforced by contract
    if (m_Kind != pathAbsoluteOther.Kind) { return false; }
    switch (m_Kind) {
       case AbsolutePathKind.DriveLetter:
          return this.DriveLetter.Equals(pathAbsoluteOther.DriveLetter);
       default:
          Debug.Assert(m_Kind == AbsolutePathKind.UNC);
          // Compare UNC server and share, with ignorcase.
          return String.Compare(this.UNCServer, pathAbsoluteOther.UNCServer, true) == 0 &&
                 String.Compare(this.UNCShare, pathAbsoluteOther.UNCShare, true) == 0;
    }
 }
			public abstract bool TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath, out string failureMessage);
			public abstract VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath,
				out IReadOnlyList<string> unresolvedVariables);
 // This methods are implemented in EnvVarFilePath and EnvVarDirectoryPath.
 public abstract EnvVarPathResolvingStatus TryResolve(out IAbsolutePath pathResolved);
			public override EnvironmentVariableResolvingStatus TryResolve(out IAbsolutePath resolvedPath)
			{
				IAbsoluteDirectoryPath directoryPath;

				var resolvingStatus = TryResolve(out directoryPath);

				resolvedPath = directoryPath;

				return resolvingStatus;
			}
示例#37
0
 public EnvVarPathResolvingStatus TryResolve(out IAbsolutePath pathResolved)
 {
     throw new NotImplementedException();
 }
			public override bool TryResolve(out IAbsolutePath resolvedPath, out string failureMessage)
			{
				IAbsoluteDirectoryPath directoryPath;

				var result = TryResolve(out directoryPath, out failureMessage);

				resolvedPath = directoryPath;

				return result;
			}
 public override VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variablesValues, out IAbsolutePath pathResolved)
 {
     IAbsoluteDirectoryPath pathDirectoryResolved;
     var resolvingStatus = this.TryResolve(variablesValues, out pathDirectoryResolved);
     pathResolved = pathDirectoryResolved;
     return resolvingStatus;
 }
			public override bool TryResolve(out IAbsolutePath resolvedPath, out string failureMessage)
			{
				IAbsoluteFilePath filePath;

				var result = TryResolve(out filePath, out failureMessage);

				resolvedPath = filePath;

				return result;
			}
			public override EnvironmentVariableResolvingStatus TryResolve(out IAbsolutePath resolvedPath)
			{
				IAbsoluteFilePath filePath;

				var resolvingStatus = TryResolve(out filePath);

				resolvedPath = filePath;

				return resolvingStatus;
			}
			public override VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath)
			{
				IAbsoluteDirectoryPath directoryPath;

				var resolvingStatus = TryResolve(variables, out directoryPath);

				resolvedPath = directoryPath;

				return resolvingStatus;
			}
			public override bool TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath, out string failureMessage)
			{
				IAbsoluteDirectoryPath directoryPath
					;
				var b = TryResolve(variables, out directoryPath, out failureMessage);

				resolvedPath = directoryPath;

				return b;
			}
 public override bool TryResolve(IEnumerable<KeyValuePair<string, string>> variablesValues, out IAbsolutePath pathResolved, out string failureReason) {
    IAbsoluteFilePath pathFileResolved;
    var b = this.TryResolve(variablesValues, out pathFileResolved, out failureReason);
    pathResolved = pathFileResolved;
    return b;
 }
示例#45
0
 public VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variablesValues, out IAbsolutePath pathResolved, out IReadOnlyList<string> unresolvedVariables)
 {
     Contract.Requires(variablesValues != null, "variablesValues must not be null");
      throw new NotImplementedException();
 }
 public override EnvVarPathResolvingStatus TryResolve(out IAbsolutePath pathResolved) {
    IAbsoluteFilePath pathFileResolved;
    var resolvingStatus = this.TryResolve(out pathFileResolved);
    pathResolved = pathFileResolved;
    return resolvingStatus;
 }
 public override bool TryResolve(out IAbsolutePath pathResolved, out string failureReason) {
    IAbsoluteFilePath pathFileResolved;
    var b = this.TryResolve(out pathFileResolved, out failureReason);
    pathResolved = pathFileResolved;
    return b;
 }
			public bool OnSameVolumeThan(IAbsolutePath otherAbsolutePath)
			{
				Argument.IsNotNull(nameof(otherAbsolutePath), otherAbsolutePath);

				if (Type != otherAbsolutePath.Type)
				{
					return false;
				}

				if (Type == AbsolutePathType.DriveLetter)
				{
					return DriveLetter.Equals(otherAbsolutePath.DriveLetter);
				}
				
				return string.Compare(UNCServer, otherAbsolutePath.UNCServer, StringComparison.OrdinalIgnoreCase) == 0 &&
					   string.Compare(UNCShare, otherAbsolutePath.UNCShare, StringComparison.OrdinalIgnoreCase) == 0;
			}
示例#49
0
 public bool ComparePathsOsCaseSensitive(IAbsolutePath path1, IAbsolutePath path2) {
     return GetFullCleanPath(path1.ToString()).Equals(GetFullCleanPath(path2.ToString()));
 }
			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;
			}
示例#51
0
 public bool TryResolve(out IAbsolutePath pathResolved, out string failureReason)
 {
     throw new NotImplementedException();
 }
			public abstract VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath);
 public override VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variablesValues, out IAbsolutePath pathResolved, out IReadOnlyList<string> unresolvedVariables) {
    IAbsoluteFilePath pathFileResolved;
    var resolvingStatus = this.TryResolve(variablesValues, out pathFileResolved, out unresolvedVariables);
    pathResolved = pathFileResolved;
    return resolvingStatus;
 }
			public override VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath,
				out IReadOnlyList<string> unresolvedVariables)
			{
				IAbsoluteFilePath filePath;

				var resolvingStatus = TryResolve(variables, out filePath, out unresolvedVariables);

				resolvedPath = filePath;

				return resolvingStatus;
			}
示例#55
0
 public bool TryResolve(IEnumerable<KeyValuePair<string, string>> variablesValues, out IAbsolutePath pathResolved, out string failureReason)
 {
     Contract.Requires(variablesValues != null, "variablesValues must not be null");
      throw new NotImplementedException();
 }
 public abstract bool TryResolve(IEnumerable<KeyValuePair<string, string>> variablesValues, out IAbsolutePath pathResolved, out string failureReason);
 public abstract bool TryResolve(out IAbsolutePath pathResolved, out string failureReason);
 public abstract bool OnSameVolumeThan(IAbsolutePath pathAbsoluteOther);
			public override bool TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsolutePath resolvedPath, out string failureMessage)
			{
				IAbsoluteFilePath filePath;

				var result = TryResolve(variables, out filePath, out failureMessage);

				resolvedPath = filePath;

				return result;
			}
 public abstract bool TryResolveEnvironmentVariable(out IAbsolutePath pathResolved);