コード例 #1
0
        private static List <string> init_genius_cmd(string appdata_dir)
        {
            List <string> all_cmd       = Static_data.cmd_linux_commands();
            List <int>    all_cmd_usage = new List <int>();
            List <string> all_content   = new List <string>();

            for (int i = 0; i < all_cmd.Count; i++)
            {
                all_cmd_usage.Add(-1);
            }
            int start_index;

            if (File.Exists(appdata_dir + "/genius_data/genius_data_cmd"))
            {
                try
                {
                    all_content = Library.getFileContent(appdata_dir + "/genius_data/genius_data_cmd");

                    for (int i = 0; i < all_content.Count; i++)
                    {
                        start_index = 1;
                        while (all_content[i][start_index] != ':')
                        {
                            start_index++;
                        }
                        start_index++;

                        Static_data.match_cmd_with_cmd_linux_command(ref all_cmd_usage, all_content[i].Substring(0, start_index - 1), Convert.ToInt32(all_content[i].Substring(start_index, all_content[i].Length - start_index)));
                    }

                    if (!all_genius_cmd_found(ref all_cmd_usage))
                    {
                        reinit_file_genius_data_cmd(appdata_dir, all_cmd, all_cmd_usage);
                    }

                    all_cmd = sort_genius_cmd(all_cmd, all_cmd_usage);
                    return(all_cmd);
                }
                catch (Exception)
                {
                }
            }

            all_genius_cmd_found(ref all_cmd_usage);
            reinit_file_genius_data_cmd(appdata_dir, all_cmd, all_cmd_usage);

            return(all_cmd);
        }
コード例 #2
0
        private static string find_appdata()
        {
            char racine = 'A';
            int  i      = 0;

            while (i < 26 && !Directory.Exists(racine + ":/Users/" + Environment.UserName + "/AppData/Roaming/Kelmatou Apps/cmd Linux/"))
            {
                i++;
                racine = (char)(racine + 1);
            }

            if (26 == i)
            {
                racine = 'A';
                i      = 0;
                while (i < 26 && !Directory.Exists(racine + ":/"))
                {
                    i++;
                    racine = (char)(racine + 1);
                }

                if (i == 26)
                {
                    Console.Clear();
                    Console.Write("> ");
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("cmd Linux: FATAL ERROR: can't find application ressources!");
                    Console.ResetColor();
                    Console.Write("> ");
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("cmd Linux: try to reinstall the application");
                    Console.ResetColor();
                    return("");
                }
                else
                {
                    try
                    {
                        Directory.CreateDirectory(racine + ":/Users/" + Environment.UserName + "/AppData/Roaming/Kelmatou Apps/cmd Linux/");
                        Directory.CreateDirectory(racine + ":/Users/" + Environment.UserName + "/AppData/Roaming/Kelmatou Apps/cmd Linux/genius_data");
                        string       appdata_dir = racine + ":/Users/" + Environment.UserName + "/AppData/Roaming/Kelmatou Apps/cmd Linux/";
                        StreamWriter eraser;
                        for (int j = 0; j < Static_data.cmd_linux_commands().Count; j++)
                        {
                            if (Static_data.has_genius_data_file(Static_data.cmd_linux_commands()[j]))
                            {
                                if (Static_data.cmd_linux_commands()[j][Static_data.cmd_linux_commands()[j].Length - 1] == ';')
                                {
                                    eraser = new StreamWriter(appdata_dir + "genius_data/" + Static_data.cmd_linux_commands()[j].Substring(0, Static_data.cmd_linux_commands()[j].Length - 1));
                                }
                                else
                                {
                                    eraser = new StreamWriter(appdata_dir + "genius_data/" + Static_data.cmd_linux_commands()[j]);
                                }
                                eraser.Close();
                            }
                        }
                        eraser = new StreamWriter(appdata_dir + "/skype_location");
                        eraser.Close();
                        eraser = new StreamWriter(appdata_dir + "/ts_location");
                        eraser.Close();
                        eraser = new StreamWriter(appdata_dir + "/lolapp_location");
                        eraser.Close();
                        eraser = new StreamWriter(appdata_dir + "/cmd.bat");
                        eraser.Close();
                        return(appdata_dir);
                    }
                    catch (Exception)
                    {
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.Write("> cmd Linux: FATAL ERROR: can't find application ressources!");
                        Console.Write("> cmd Linux: try to reinstall the application");
                        return("");
                    }
                }
            }
            else
            {
                return(racine + ":/Users/" + Environment.UserName + "/AppData/Roaming/Kelmatou Apps/cmd Linux/");
            }
        }