コード例 #1
0
ファイル: BuildFsFileSystem.cs プロジェクト: tronsoft/BuildFs
        public static BuildFsFileSystem Mount(char letter, DokanOptions options)
        {
            Dokan.Unmount(letter);

            var fs = new BuildFsFileSystem();

            fs.Letter = letter;
            var t = Task.Run(() => Dokan.Mount(fs, letter + ":", options, 1));
            var e = Stopwatch.StartNew();

            while (e.ElapsedMilliseconds < 3000)
            {
                Thread.Sleep(200);
                if (t.Exception != null)
                {
                    throw t.Exception;
                }
                if (Directory.Exists(letter + ":\\"))
                {
                    return(fs);
                }
            }
            return(fs);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var letter = 'R';

            var chan = new IpcChannel(BuildFs.BuildFsApi.IpcChannelName);

            ChannelServices.RegisterChannel(chan, false);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(BuildFsApiImpl), BuildFsApi.IpcChannelName, WellKnownObjectMode.Singleton);

            var fs = BuildFsFileSystem.Mount(letter, DokanOptions.FixedDrive);

            //fs.ForceRun = true;
            BuildFsApiImpl.Run = (location, commandLine, folder, custom) =>
            {
                try
                {
                    if (custom)
                    {
                        folder = Path.GetFullPath(folder);
                        var components = folder.SplitFast('\\', StringSplitOptions.RemoveEmptyEntries);
                        if (components[0].ToUpper() != letter + ":")
                        {
                            throw new Exception("Must be run in BuildFs drive.");
                        }

                        string exe;
                        string arguments;
                        BuildFsApi.ParseCommandLine(commandLine, out exe, out arguments);
                        commandLine = arguments;
                        BuildFsApi.ParseCommandLine(commandLine, out exe, out arguments);

                        fs.RunCached(components[1], string.Join("\\", components.Skip(2)), exe, arguments);
                    }
                    else
                    {
                        var    projname = "project";
                        var    find     = @"C:\Path\To\Project";
                        var    replace  = letter + @":\" + projname;
                        string exe;
                        string arguments;
                        folder      = folder.Replace(find, replace);
                        commandLine = commandLine.Replace(find, replace);
                        BuildFsApi.ParseCommandLine(commandLine, out exe, out arguments);

                        var realexe = Path.Combine(Path.GetDirectoryName(location), Path.GetFileNameWithoutExtension(location) + "-real.exe");
                        fs.RunCached(projname, folder, realexe, new ProcessUtils.RawCommandLineArgument(arguments));
                    }
                    Console.WriteLine("Success.");
                    return(0);
                }
                catch (ProcessException ex)
                {
                    Console.WriteLine("Failed with " + ex.ExitCode);
                    return(ex.ExitCode);
                }
            };


            //MainInternal(args, fs);


            // Example:

            //fs.AddProject(@"C:\Path\To\Project", "project");
            //fs.RunCached("project", "subdir", "nmake", "part-1");
            //fs.RunCached("project", "subdir", "nmake", "part-2");



            while (true)
            {
                Thread.Sleep(400000);
            }
        }