Beispiel #1
0
        public static bool delete(string user)
        {
            bool flag = false;

            user = user.ToLower();
            string str = UserDb.fname(user) + ".new";

            lock (UserDb.mylock)
            {
                StreamReader streamReader;
                StreamWriter streamWriter;
                try
                {
                    streamReader = new StreamReader(UserDb.fname(user));
                    streamWriter = new StreamWriter(str);
                }
                catch
                {
                    return(false);
                }
                while (true)
                {
                    string line;
                    User   user1;
                    do
                    {
                        line = streamReader.ReadLine();
                        if (line != null)
                        {
                            user1 = UserDb.read_line(line);
                        }
                        else
                        {
                            goto label_9;
                        }
                    }while (user1 == null);
                    if (user1.user == user)
                    {
                        flag = true;
                    }
                    else
                    {
                        streamWriter.WriteLine(line);
                    }
                }
label_9:
                streamReader.Close();
                streamWriter.Close();
                File.Delete(UserDb.fname(user));
                File.Move(str, UserDb.fname(user));
            }
            return(flag);
        }
Beispiel #2
0
        public static bool search_one(string fn, string user, UserDb.search_cb bob, object obj)
        {
            StreamReader streamReader;

            try
            {
                streamReader = new StreamReader(fn);
            }
            catch
            {
                return(true);
            }
            clib.imsg("search_one: reading file {0} and search for [{0}]", (object)fn, (object)user);
            User info;

            do
            {
                do
                {
                    string line = streamReader.ReadLine();
                    if (line != null)
                    {
                        info = UserDb.read_line(line);
                    }
                    else
                    {
                        goto label_8;
                    }
                }while (info == null || user != "" && !info.user.Contains(user));
                clib.imsg("showing user: {0}", (object)info.user);
            }while (bob(obj, info));
            return(false);

label_8:
            streamReader.Close();
            return(true);
        }
Beispiel #3
0
        public static User lookup(string user)
        {
            User user1 = (User)null;

            user = user.ToLower();
            StreamReader streamReader;

            try
            {
                streamReader = new StreamReader(UserDb.fname(user));
            }
            catch
            {
                return((User)null);
            }
            while (true)
            {
                User user2;
                do
                {
                    string line = streamReader.ReadLine();
                    if (line != null)
                    {
                        user2 = UserDb.read_line(line);
                    }
                    else
                    {
                        goto label_6;
                    }
                }while (user2 == null || user2.user != user);
                user1 = user2;
            }
label_6:
            streamReader.Close();
            return(user1);
        }