Stream OpenOutput(string gitExe, string fileName, string blobHash)
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }
            if (blobHash == null)
            {
                return(null);
            }

            AnonymousPipeServerStream pipe = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);

            StartupInfo startupInfo = new GitVersionProvider.StartupInfo();

            startupInfo.dwFlags    = STARTF_USESTDHANDLES;
            startupInfo.hStdOutput = pipe.ClientSafePipeHandle;
            startupInfo.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
            startupInfo.hStdError  = GetStdHandle(STD_ERROR_HANDLE);
            startupInfo.cb         = 16;

            PROCESS_INFORMATION procInfo;

            string commandLine = "\"" + gitExe + "\" cat-file blob " + blobHash;
            string workingDir  = Path.GetDirectoryName(fileName);

            Debug.WriteLine(workingDir + "> " + commandLine);
            const uint CREATE_NO_WINDOW = 0x08000000;

            if (!CreateProcess(null, commandLine,
                               IntPtr.Zero, IntPtr.Zero, true, CREATE_NO_WINDOW, IntPtr.Zero, workingDir, ref startupInfo,
                               out procInfo))
            {
                pipe.DisposeLocalCopyOfClientHandle();
                pipe.Close();
                return(null);
            }

            pipe.DisposeLocalCopyOfClientHandle();

            return(pipe);
        }
示例#2
0
		Stream OpenOutput(string gitExe, string fileName, string blobHash)
		{
			if (!File.Exists(fileName))
				return null;
			if (blobHash == null)
				return null;
			
			AnonymousPipeServerStream pipe = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);
			
			StartupInfo startupInfo = new GitVersionProvider.StartupInfo();
			startupInfo.dwFlags = STARTF_USESTDHANDLES;
			startupInfo.hStdOutput = pipe.ClientSafePipeHandle;
			startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
			startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
			startupInfo.cb = 16;
			
			PROCESS_INFORMATION procInfo;
			
			string commandLine = "\"" + gitExe + "\" cat-file blob " + blobHash;
			string workingDir = Path.GetDirectoryName(fileName);
			Debug.WriteLine(workingDir + "> " + commandLine);
			const uint CREATE_NO_WINDOW = 0x08000000;
			if (!CreateProcess(null, commandLine,
			                   IntPtr.Zero, IntPtr.Zero, true, CREATE_NO_WINDOW, IntPtr.Zero, workingDir, ref startupInfo,
			                   out procInfo)) {
				pipe.DisposeLocalCopyOfClientHandle();
				pipe.Close();
				return null;
			}
			
			pipe.DisposeLocalCopyOfClientHandle();
			
			return pipe;
		}
		Stream OpenOutput(string fileName, string blobHash)
		{
			if (blobHash == null)
				return null;
			
			AnonymousPipeServerStream pipe = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);
			
			StartupInfo startupInfo = new GitVersionProvider.StartupInfo();
			startupInfo.dwFlags = STARTF_USESTDHANDLES;
			startupInfo.hStdOutput = pipe.ClientSafePipeHandle;
			startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
			startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
			startupInfo.cb = 16;
			
			PROCESS_INFORMATION procInfo;
			
			if (!CreateProcess(null, string.Format("cmd /c git cat-file blob {0}", blobHash),
			                   IntPtr.Zero, IntPtr.Zero, true, 0, IntPtr.Zero, Path.GetDirectoryName(fileName), ref startupInfo,
			                   out procInfo)) {
				pipe.DisposeLocalCopyOfClientHandle();
				pipe.Close();
				return null;
			}
			
			pipe.DisposeLocalCopyOfClientHandle();
			
			return pipe;
		}