Esempio n. 1
0
        /// <summary>
        /// 构建目录结构(包括根目录,设备文件目录以及其他一些目录等等)
        /// </summary>
        private void ConstructDirectoryStruct()
        {
            DirFile rootDir = new DirFile(_superBlock, _inodeBlock, _dataBlock, _disk, "");

            rootDir.CreateDirectory();

            DirFile devDir = new DirFile(_superBlock, _inodeBlock, _dataBlock, _disk, "/dev");

            devDir.CreateDirectory();

            DevFile ttyDevFile = new DevFile(_superBlock, _inodeBlock, _dataBlock, _disk, "/dev/tty1", "tty");

            ttyDevFile.CreateFile();

            DevFile ttyDevFile = new DevFile(_superBlock, _inodeBlock, _dataBlock, _disk, "/dev/tty2", "tty");

            ttyDevFile.CreateFile();

            WriteWholeDir();
        }
Esempio n. 2
0
        /// <summary>
        /// 遍历MachinePara.ProgramDirPath所指向的目录,将其目录结构复制到根目录"/"下
        /// </summary>
        private void WriteWholeDir()
        {
            Queue <string> dirQueue = new Queue <string>();

            dirQueue.Enqueue("/");

            while (dirQueue.Count != 0)
            {
                //要在V6++系统中创建文件的路径
                string dirV6Path = dirQueue.Dequeue();
                //实际文件的路径
                string        dirRealPath = MachinePara.ProgramDirPath + dirV6Path;
                DirectoryInfo theFolder   = new DirectoryInfo(dirRealPath);

                //创建文件
                foreach (FileInfo file in theFolder.GetFiles())
                {
                    string     createFilePath = dirV6Path + "/" + file.Name;
                    CommonFile commonFile     = new CommonFile(_superBlock, _inodeBlock, _dataBlock, _disk, createFilePath, file.FullName);
                    commonFile.CreateFile();
                }
                //创建文件夹
                foreach (DirectoryInfo directory in theFolder.GetDirectories())
                {
                    if ((directory.Attributes & FileAttributes.Hidden) != 0)
                    {
                        continue;
                    }

                    string  dirPath = dirV6Path + "/" + directory.Name;
                    DirFile dirFile = new DirFile(_superBlock, _inodeBlock, _dataBlock, _disk, dirPath);
                    dirFile.CreateDirectory();
                    dirQueue.Enqueue(dirPath);
                }
            }
        }