Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileLocator"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string MakeRelativePath(IFileLocator fileLocator, string path)
        {
            if (!HasCommonRoot(fileLocator))
            {
                return(null);
            }

            string ourFullPath   = GetFullPath(string.Empty) + @"\";
            string otherFullPath = fileLocator.GetFullPath(path);

            return(Util.MakeRelativePath(otherFullPath, ourFullPath));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalFileLocator"/> class.
 /// </summary>
 /// <param name="dir"></param>
 public LocalFileLocator(IFileLocator basePath, string dir)
 {
     this.dir = basePath.GetFullPath(dir);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            List <string> extraArgs = new List <string>();
            bool          showHelp = false, runForceDebug = false, displayInterfaces = false;

            // setup the common app path
            if (!CommonAppData.PathExists(EmuService.ServiceInstallName))
            {
                Directory.CreateDirectory(CommonAppData.GetFullPath(EmuService.ServiceInstallName));
            }

            // configure trace logger
            Messages.SetupTextWriter(ProgramCommonData.GetFullPath(), EmuService.ServiceInstallName + "-Trace.log");

            Console.WriteLine(AssemblyVersion._VERSION_STRING + " (Built: " + AssemblyVersion._BUILD_DATE + ")");
            Console.WriteLine(AssemblyVersion._COPYRIGHT + "., All Rights Reserved.");
            Console.WriteLine();

            if (args.Length == 0)
            {
                Console.Error.WriteLine("Do not start the PCemu as a normal program!");
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new EmuService()
                };

                ServiceBase.Run(ServicesToRun);
            }

            // command line parameters
            OptionSet options = new OptionSet()
            {
                { "h|help", "show this message and exit", v => showHelp = v != null },
                { "i=|interface=", "interface to capture and send packets on", v => { Messages.Trace("interface [" + v + "]"); interfaceToUse = Convert.ToInt32(v); } },
                { "display-interfaces", "display interfaces to use for packet capture", v => displayInterfaces = v != null },
#if WIN32
                { "install-service", "install the server as a service on Windows computers", v => InstallService() },
                { "uninstall-service", "uninstall the server as a service on Windows computers", v => UninstallService() },
#endif
                { "force-debug", "force the server to run in debug mode", v => runForceDebug = v != null },
            };

            // attempt to parse the commandline
            try
            {
                extraArgs = options.Parse(args);
            }
            catch (OptionException)
            {
                Console.WriteLine("error: invalid arguments");
                Usage(options);
                Environment.Exit(1);
            }

            // show help
            if (showHelp)
            {
                Usage(options);
            }

            if (runForceDebug)
            {
                ForceDebug(args);
            }

            if (displayInterfaces)
            {
                DisplayInterfaces();
            }

            Environment.Exit(0);
        }