Esempio n. 1
0
        /// <summary>
        /// 返回上一级目录
        /// </summary>
        /// <param name="u"></param>
        public static void back(User u)
        {
            string tpath = TruepathParser.parse(u);
            int    point = tpath.LastIndexOf(@"\");

            tpath = tpath.Substring(0, point);
            u.SetPath(LogicalParser.parse(tpath, u));
            u.SetSinglePath(LogicalParser.singleParse(u));
        }
        /// <summary>
        /// 更新索引表.
        /// </summary>
        /// <param name="u"></param>
        public static void Update(User u)
        {
            string[]      fds = FDfiner.find(TruepathParser.parse(u)).Split('\n');
            StringBuilder sb  = new StringBuilder();

            foreach (string fd in fds)
            {
                sb.AppendLine(LogicalParser.parse(fd, u));
            }
            IndexTableWriter.Write(u, sb.ToString(), false);
        }
Esempio n. 3
0
        /// <summary>
        /// 进入下一级目录
        /// </summary>
        /// <param name="u"></param>
        /// <param name="cmd"></param>
        public static void fore(User u, string cmd)
        {
            string nextDir = cmd;

            if (!Directory.Exists(TruepathParser.parse(u) + @"\" + nextDir))
            {
                Console.WriteLine("目录不存在");
            }
            else
            {
                u.SetPath(u.GetPath() + @"\" + nextDir);
                u.SetSinglePath(nextDir);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 删除文件夹
        /// </summary>
        /// <param name="u"></param>
        /// <param name="dname"></param>
        public static void deletedir(User u, string dname)
        {
            if (dname.StartsWith(@".\"))
            {
                dname = dname.Substring(2);
            }
            string tpath = TruepathParser.parse(u);

            try
            {
                Directory.Delete(tpath + @"\" + dname, true);
            }
            catch (Exception e)
            {
                Console.WriteLine("找不到该文件夹");
            }
            //更新索引表
            IndexTableOperation.Update(u);
        }
Esempio n. 5
0
        /// <summary>
        /// 新建文件夹
        /// </summary>
        /// <param name="u"></param>
        /// <param name="dname">文件夹名字</param>
        public static void makedir(User u, string dname)
        {
            if (dname.StartsWith(@".\"))
            {
                dname = dname.Substring(2);
            }
            string tpath = TruepathParser.parse(u);

            if (Directory.Exists(tpath + @"\" + dname))
            {
                Console.WriteLine("该文件夹已存在");
            }
            else
            {
                Directory.CreateDirectory(tpath + @"\" + dname);
            }
            //向索引表添加记录
            IndexTableWriter.Write(u, u.GetPath() + @"\" + dname, true);
        }
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="u"></param>
        /// <param name="fname"></param>
        public static void delete(User u, string fname)
        {
            if (fname.StartsWith(@".\"))
            {
                fname = fname.Substring(2);
            }
            string tpath = TruepathParser.parse(u);

            try
            {
                File.Delete(tpath + @"\" + fname);
            }
            catch (Exception e)
            {
                Console.WriteLine("找不到该文件");
            }
            //更新索引表
            IndexTableOperation.Update(u);
        }
        /// <summary>
        /// 创建文件
        /// </summary>
        /// <param name="u"></param>
        /// <param name="fname"></param>
        public static void create(User u, string fname)
        {
            if (fname.StartsWith(@".\"))
            {
                fname = fname.Substring(2);
            }
            string tpath = TruepathParser.parse(u);

            if (File.Exists(tpath + @"\" + fname))
            {
                Console.WriteLine("该文件夹已存在");
            }
            else
            {
                File.Create(tpath + @"\" + fname).Close();
            }
            //向索引表添加记录
            IndexTableWriter.Write(u, u.GetPath() + @"\" + fname, true);
        }