Beispiel #1
0
        public static CCTableConfModel[] GetServices(this string[] array)
        {
            var list = new HashSet <CCTableConfModel>();

            foreach (var t in array)
            {
                var conf = t;
                if (t.Contains("\\"))
                {
                    conf = t.Replace("\\", "/");
                }
                var confNameSplit = conf.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                if (confNameSplit.Length < 3)
                {
                    continue; //so che è una cartella perché c'è altro dopo
                }
                if (confNameSplit[1].EndsWith(".d"))
                {
                    continue;
                }
                //e so che non è una cartella con dentro delle conf da non toccare
                if (list.Any(l => l.Name == confNameSplit[1]))
                {
                    continue;
                }
                //nella mia lista non c'è già un entry con il nome uguale (a confNameSplit[1])
                var m = new CCTableConfModel {
                    Name = confNameSplit[1],
                    Path = $"/etc/{confNameSplit[1]}",
                    Type = CCTableFlags.ConfType.Directory
                };
                list.Add(m);
            }
            return(list.ToArray());
        }
Beispiel #2
0
        public static CCTableConfModel[] GetConfFiles(this string[] array)
        {
            var list = new HashSet <CCTableConfModel>();

            foreach (var t in array)
            {
                var conf = t;
                if (t.Contains("\\"))
                {
                    conf = t.Replace("\\", "/");
                }
                var confNameSplit = conf.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                if (confNameSplit.Length >= 3)
                {
                    continue; //so che è un file perché non c'è niente dopo
                }
                if (!conf.EndsWith(".conf"))
                {
                    continue; //e so che è un file .conf
                }
                var m = new CCTableConfModel {
                    Name = confNameSplit[1],
                    Path = $"/etc/{confNameSplit[1]}",
                    Type = CCTableFlags.ConfType.File
                };
                list.Add(m);
            }
            return(list.ToArray());
        }