public static void rights(string name, string path, string rights)
        {
            Regex regex_d = new Regex(@"^(?<files>[r-][w-]-[r-][w-])");
            Match matches = regex_d.Match(rights);

            if (matches.Success)
            {
                TypeOf r = function_file.search_Type_Of(name, path);
                //Если директория или файл найдены...
                if (r.name != "")
                {
                    //Если учетная запись админа или если создателю можно записывать, или если другим пользователям можно записывать
                    if ((Main.Sess.user_name == "admin") ||
                        ((r.attributes.di_uid == Main.Sess.user_name) && (function_inode.rights_for_all(r)[1])) ||
                        ((function_inode.rights_for_all(r)[3])))
                    {
                        r.attributes.dimode.rights = rights;
                    }
                    else
                    {
                        Program.myForm.Log.Text += "У вас нет прав для изменения прав доступа!\n\n";
                    }
                }
                else
                {
                    Program.myForm.Log.Text += "Данной директории или файла не существует!\n\n";
                }
            }
        }
Beispiel #2
0
        public static TypeOf search_Type_Of(string f, string path)
        {
            string[] path_l = path.Split('/');
            catalog  temp   = new catalog();

            temp.attributes = Main.Root.attributes;
            temp.name       = Main.Root.name;
            temp.List       = Main.Root.List;

            for (int i = 0; i < path_l.Count() - 1; i++)
            {
                temp.name = path_l[i];
                for (int j = 0; j < temp.List.Count; j++)
                {
                    if ((temp.List[j].name == path_l[i]) && (i != path_l.Count()))
                    {
                        temp.attributes = temp.List[j].attributes;
                        temp.name       = temp.List[j].name;
                        catalog ab = (catalog)temp.List[j];
                        temp.List = ab.List;
                    }
                }
            }
            for (int y = 0; y < temp.List.Count; y++)
            {
                if (f == temp.List[y].name)
                {
                    TypeOf t = temp.List[y];
                    return(t);
                }
            }
            TypeOf r = new TypeOf();

            return(r);
        }
Beispiel #3
0
        public static string attr(string dir, string path)
        {
            TypeOf t   = search_Type_Of(dir, path);
            string res = string.Empty;

            //Если файл найден...
            if (t.name != "")
            {
                res += "Имя файла: " + t.name + "\nТип: " + t.attributes.dimode.type + "\nРазмер: " + t.attributes.di_size + "\nВладелец: " + t.attributes.di_uid;
                res += "\nСоздан: " + t.attributes.di_ctime + "\nИзменен: " + t.attributes.di_mtime + "\nПрава: " + t.attributes.dimode.rights + "\n\n";
            }
            else
            {
                res = "Файла с таким именем не существует!\n\n";
            }
            return(res);
        }
        public static Boolean[] rights_for_all(TypeOf t)
        {
            Boolean[] ret = new Boolean[4];
            ret[0] = false;
            ret[1] = false;
            ret[2] = false;
            ret[3] = false;
            Regex  regex_d = new Regex(@"^(?<reading1>[r-])(?<writing1>[w-])-(?<reading2>[r-])(?<writing2>[w-])");
            Match  matches = regex_d.Match(t.attributes.dimode.rights);
            string r1      = String.Empty;
            string w1      = String.Empty;
            string r2      = String.Empty;
            string w2      = String.Empty;

            if (matches.Success)
            {
                r1 = matches.Groups["reading1"].Value.ToString();
                w1 = matches.Groups["writing1"].Value.ToString();
                r2 = matches.Groups["reading2"].Value.ToString();
                w2 = matches.Groups["writing2"].Value.ToString();
                if (r1 == "r")
                {
                    ret[0] = true;
                }
                if (w1 == "w")
                {
                    ret[1] = true;
                }
                if (r2 == "r")
                {
                    ret[2] = true;
                }
                if (w2 == "w")
                {
                    ret[3] = true;
                }
            }
            return(ret);
        }