Ejemplo n.º 1
0
 void fsw_Created(object sender, FileSystemEventArgs e)
 {
     FileInfo info = new FileInfo(e.FullPath);
     if (!ExtensionsToListen.Contains(info.Extension))
     {
         return;
     }
     Makefile make = new Makefile();
     make.Create(OSPath);
 }
Ejemplo n.º 2
0
        void fsw_Deleted(object sender, FileSystemEventArgs e)
        {
            try
            {
                FileInfo info = new FileInfo(e.FullPath);
                if (info.Extension == "")
                {

                }
                else if (!ExtensionsToListen.Contains(info.Extension))
                {
                    //Check if it was a folder or a file. If a file then check its extension to make sure we're not renaming/deleting .txt or something
                    return;
                }
                string transformed = Makefile.TransformSourcePath(OSPath, info).Replace('/', '\\');
                string obj_folder;
                if (Program.Options["temp"])
                {
                    obj_folder = "/tmp/";
                }
                else
                {
                    obj_folder = "obj/";
                }
                File.Delete(OSPath + obj_folder + transformed + (info.Extension != "" ? ".o" : ""));
                //Delete the old object
            }
            catch
            {

            }
            //Delete the old object
            Makefile make = new Makefile();
            make.Create(OSPath);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Options = new Dictionary<string, bool>();
            Options.Add("temp", false);
            Options.Add("ggdb", false);

            string osPath = "C:\\OS\\";
            Watch watch = new Watch();

            Console.WriteLine("**** Hydra Makefile Generator ****");
            PrintHelp();
            while (true)
            {
                Console.Write(">");
                string input = Console.ReadLine();
                input = input.ToLower();
                string[] splitInput=input.Split(' ');
                switch (splitInput[0])
                {
                    default:
                        Console.WriteLine("Command not found");
                        break;
                    case "enable":
                        for(int i=1;i<splitInput.Length;i++)
                        {
                            string option=splitInput[i];
                            if(Options.ContainsKey(option))
                            {
                                Options[option] = true;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("Error: option {0} not found");
                                Console.ResetColor();
                            }
                        }
                        Console.WriteLine("Done.");
                        break;
                    case "disable":
                        for (int i = 1; i < splitInput.Length; i++)
                        {
                            string option = splitInput[i];
                            if (Options.ContainsKey(option))
                            {
                                Options[option] = false;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("Error: option {0} not found");
                                Console.ResetColor();
                            }
                        }
                        Console.WriteLine("Done.");
                        break;
                    case "now":
                        {
                            Makefile makefile = new Makefile();
                            makefile.Create(osPath);
                        }
                        break;
                    case "clean":
                        {
                            Directory.Delete(osPath + "obj", true);
                            Directory.CreateDirectory(osPath + "obj");
                            Makefile makefile = new Makefile();
                            makefile.Create(osPath);
                        }
                        break;
                    case "exit":
                        return;
                    case "help":
                        if (splitInput.Length == 1)
                        {
                            PrintHelp();
                        }
                        else if(splitInput[1]=="options")
                        {
                            PrintOptions();
                        }
                        else
                        {
                            Console.WriteLine("Help not found");
                        }
                        break;
                    case "set":
                        input = input.Remove(0, 4);
                        //Input is the new path
                        try
                        {
                            DirectoryInfo info = new DirectoryInfo(input);
                            if (!info.Exists)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("Error: Path doesn't exist or invalid");
                                Console.ResetColor();
                            }
                            //Format check
                            if (input.Last() != '\\' && input.Last() != '/')
                            {
                                input += '\\';
                            }
                            osPath = input;
                            Console.WriteLine("Done.");
                        }
                        catch
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Error: Path doesn't exist or invalid");
                            Console.ResetColor();
                        }
                        break;
                    case "start":
                        watch.Start(osPath);
                        break;
                    case "stop":
                        watch.Stop();
                        break;
                }
            }
        }