Inheritance: IDisposable
Exemple #1
0
 protected void LoadRootIsoNode()
 {
     this.Stream.Position         = SectorSize * 0x10;
     this.PrimaryVolumeDescriptor = this.Stream.ReadStruct <PrimaryVolumeDescriptor>();
     this.Root = new IsoNode(this, PrimaryVolumeDescriptor.DirectoryRecord);
     ProcessDirectoryRecord(this.Root);
 }
Exemple #2
0
        protected void ProcessDirectoryRecord(IsoNode parentIsoNode)
        {
            var directoryStart  = parentIsoNode.DirectoryRecord.Extent * SectorSize;
            var directoryLength = parentIsoNode.DirectoryRecord.Size;
            var directoryStream = Stream.SliceWithLength(directoryStart, directoryLength);

            while (!directoryStream.Eof())
            {
                //writefln("%08X : %08X : %08X", directoryStream.position, directoryStart, directoryLength);
                var directoryRecordSize = (byte)directoryStream.ReadByte();

                // Even if a directory spans multiple sectors, the directory entries are not permitted to cross the sector boundary (unlike the path table).
                // Where there is not enough space to record an entire directory entry at the end of a sector, that sector is zero-padded and the next
                // consecutive sector is used.
                if (directoryRecordSize == 0)
                {
                    directoryStream.Position = MathUtils.NextAligned(directoryStream.Position, SectorSize);
                    //Console.WriteLine("AlignedTo: {0:X}", DirectoryStream.Position);
                    continue;
                }

                directoryStream.Position = directoryStream.Position - 1;

                //Console.WriteLine("[{0}:{1:X}-{2:X}]", DirectoryRecordSize, DirectoryStream.Position, DirectoryStream.Position + DirectoryRecordSize);

                var directoryRecordBytes = new byte[directoryRecordSize];
                directoryStream.Read(directoryRecordBytes, 0, directoryRecordSize);
                var directoryRecord = StructUtils.BytesToStruct <DirectoryRecord>(directoryRecordBytes);

                var name =
                    Encoding.UTF8.GetString(directoryRecordBytes.Slice(sizeof(DirectoryRecord),
                                                                       directoryRecord.NameLength));

                //Console.WriteLine("{0}", name); Console.ReadKey();

                if (name == "\x00" || name == "\x01")
                {
                    continue;
                }

                //writefln("   %s", name);

                var childIsoNode = new IsoNode(this, directoryRecord, name, parentIsoNode);
                parentIsoNode.Childs2.Add(childIsoNode);
                parentIsoNode.ChildsByName[childIsoNode.Name] = childIsoNode;
                parentIsoNode.ChildsByNameUpperCase[childIsoNode.Name.ToUpper()] = childIsoNode;
            }

            foreach (var child in parentIsoNode.Childs2)
            {
                if (child.IsDirectory)
                {
                    ProcessDirectoryRecord(child);
                }
            }
        }
Exemple #3
0
		protected void ProcessDirectoryRecord(IsoNode ParentIsoNode)
		{
			var DirectoryStart  = ParentIsoNode.DirectoryRecord.Extent * SectorSize;
			var DirectoryLength = ParentIsoNode.DirectoryRecord.Size;
			var DirectoryStream = this.Stream.SliceWithLength(DirectoryStart, DirectoryLength);

			while (!DirectoryStream.Eof())
			{
				//writefln("%08X : %08X : %08X", directoryStream.position, directoryStart, directoryLength);
				byte DirectoryRecordSize;
				DirectoryRecordSize = (byte)DirectoryStream.ReadByte();

				// Even if a directory spans multiple sectors, the directory entries are not permitted to cross the sector boundary (unlike the path table).
				// Where there is not enough space to record an entire directory entry at the end of a sector, that sector is zero-padded and the next
				// consecutive sector is used.
				if (DirectoryRecordSize == 0)
				{
					DirectoryStream.Position = MathUtils.NextAligned(DirectoryStream.Position, SectorSize);
					//Console.WriteLine("AlignedTo: {0:X}", DirectoryStream.Position);
					continue;
				}

				DirectoryStream.Position = DirectoryStream.Position - 1;

				//Console.WriteLine("[{0}:{1:X}-{2:X}]", DirectoryRecordSize, DirectoryStream.Position, DirectoryStream.Position + DirectoryRecordSize);

				byte[] DirectoryRecordBytes = new byte[DirectoryRecordSize];
				DirectoryStream.Read(DirectoryRecordBytes, 0, DirectoryRecordSize);
				var DirectoryRecord = StructUtils.BytesToStruct<DirectoryRecord>(DirectoryRecordBytes);
			
				string name = Encoding.UTF8.GetString(DirectoryRecordBytes.Slice(sizeof(DirectoryRecord), DirectoryRecord.NameLength));

				//Console.WriteLine("{0}", name); Console.ReadKey();
			
				if (name == "\x00" || name == "\x01") continue;
			
				//writefln("   %s", name);
			
				var childIsoNode = new IsoNode(this, DirectoryRecord, name, ParentIsoNode);
				ParentIsoNode._Childs.Add(childIsoNode);
				ParentIsoNode._childsByName[childIsoNode.Name] = childIsoNode;
				ParentIsoNode._childsByNameUpperCase[childIsoNode.Name.ToUpper()] = childIsoNode;
			}
		
			foreach (var child in ParentIsoNode._Childs)
			{
				if (child.IsDirectory) ProcessDirectoryRecord(child);
			}
		}
Exemple #4
0
        internal IsoNode(IsoFile Iso, DirectoryRecord directoryRecord, string name = "", IsoNode parent = null)
        {
            this.Iso             = Iso;
            this._Parent         = parent;
            this.DirectoryRecord = directoryRecord;
            if (parent != null)
            {
                this.FullPath = parent.FullPath + "/" + name;
            }
            else
            {
                this.FullPath = name;
            }
            this.Name = name;

            //writefln("%s", this.fullPath);
        }
Exemple #5
0
        public IsoNode Locate(string path)
        {
            int    index = path.IndexOf('/');
            string childName, descendencyPath;

            if (index < 0)
            {
                childName       = path;
                descendencyPath = "";
            }
            else
            {
                childName       = path.Substring(0, index);
                descendencyPath = path.Substring(index + 1);
            }
            IsoNode childIsoNode = AccessChild(childName);

            if (descendencyPath != "")
            {
                childIsoNode = childIsoNode.Locate(descendencyPath);
            }
            return(childIsoNode);
        }
Exemple #6
0
        internal IsoNode(IsoFile Iso, DirectoryRecord directoryRecord, string name = "", IsoNode parent = null)
        {
            this.Iso = Iso;
            this._Parent = parent;
            this.DirectoryRecord = directoryRecord;
            if (parent != null)
            {
                this.FullPath = parent.FullPath + "/" + name;
            }
            else
            {
                this.FullPath = name;
            }
            this.Name = name;

            //writefln("%s", this.fullPath);
        }
Exemple #7
0
 protected void LoadRootIsoNode()
 {
     this.Stream.Position = SectorSize * 0x10;
     this.PrimaryVolumeDescriptor = this.Stream.ReadStruct<PrimaryVolumeDescriptor>();
     this.Root = new IsoNode(this, PrimaryVolumeDescriptor.DirectoryRecord);
     ProcessDirectoryRecord(this.Root);
 }
Exemple #8
0
        public unsafe void _IoGetstat(IsoNode IsoNode, SceIoStat* Stat)
        {
            //IsoNode.DirectoryRecord.Date
            Stat->Mode = 0;
            Stat->Mode |= SceMode.UserCanRead | SceMode.UserCanWrite | SceMode.UserCanExecute;
            Stat->Mode |= SceMode.GroupCanRead | SceMode.GroupCanWrite | SceMode.GroupCanExecute;
            Stat->Mode |= SceMode.OtherCanRead | SceMode.OtherCanWrite | SceMode.OtherCanExecute;

            if (IsoNode.IsDirectory)
            {
                Stat->Mode = SceMode.Directory;
                Stat->Attributes = IOFileModes.Directory;
            }
            else
            {
                Stat->Mode = SceMode.File;
                Stat->Attributes = IOFileModes.File | IOFileModes.CanRead | IOFileModes.CanWrite | IOFileModes.CanExecute;
            }
            Stat->Size = IsoNode.DirectoryRecord.Size;
            Stat->TimeCreation = ScePspDateTime.FromDateTime(IsoNode.DirectoryRecord.Date);
            Stat->TimeLastAccess = ScePspDateTime.FromDateTime(IsoNode.DirectoryRecord.Date);
            Stat->TimeLastModification = ScePspDateTime.FromDateTime(IsoNode.DirectoryRecord.Date);
            Stat->DeviceDependentData0 = IsoNode.DirectoryRecord.Extent;

            //Stat[0].DeviceDependentData
            //throw new NotImplementedException();
        }