Beispiel #1
0
        public override int ioGetstat(string fileName, SceIoStat stat)
        {
            StringBuilder restFileName = new StringBuilder();
            string        umdFileName  = getUmdFileName(fileName, restFileName);

            if (!string.ReferenceEquals(umdFileName, null) && isVirtualFile(restFileName.ToString()))
            {
                return(umdIoGetstat(umdFileName, restFileName.ToString(), stat));
            }

            return(vfs.ioGetstat(fileName, stat));
        }
Beispiel #2
0
        public override int ioChstat(string fileName, SceIoStat stat, int bits)
        {
            File file = getFile(fileName);

            int  mode       = stat.mode;
            bool successful = true;

            if ((bits & 0x0001) != 0)
            {             // Others execute permission
                if (!file.Directory && !file.setExecutable((mode & 0x0001) != 0))
                {
                    successful = false;
                }
            }
            if ((bits & 0x0002) != 0)
            {             // Others write permission
                if (!file.setWritable((mode & 0x0002) != 0))
                {
                    successful = false;
                }
            }
            if ((bits & 0x0004) != 0)
            {             // Others read permission
                if (!file.setReadable((mode & 0x0004) != 0))
                {
                    successful = false;
                }
            }

            if ((bits & 0x0040) != 0)
            {             // User execute permission
                if (!file.setExecutable((mode & 0x0040) != 0, true))
                {
                    successful = false;
                }
            }
            if ((bits & 0x0080) != 0)
            {             // User write permission
                if (!file.setWritable((mode & 0x0080) != 0, true))
                {
                    successful = false;
                }
            }
            if ((bits & 0x0100) != 0)
            {             // User read permission
                if (!file.setReadable((mode & 0x0100) != 0, true))
                {
                    successful = false;
                }
            }

            return(successful ? 0 : IO_ERROR);
        }
Beispiel #3
0
        private void scan(string dirName, FatFileInfo parent)
        {
            string[] names = vfs.ioDopen(dirName);
            if (names == null || names.Length == 0)
            {
                return;
            }

            SceIoStat   stat = new SceIoStat();
            SceIoDirent dir  = new SceIoDirent(stat, null);

            for (int i = 0; i < names.Length; i++)
            {
                dir.filename = names[i];
                if (vfs.ioDread(dirName, dir) >= 0)
                {
                    bool        directory = (dir.stat.attr & 0x10) != 0;
                    bool        readOnly  = (dir.stat.mode & 0x2) == 0;
                    FatFileInfo fileInfo  = new FatFileInfo(vFile.DeviceName, dirName, dir.filename, directory, readOnly, dir.stat.mtime, dir.stat.size);

                    parent.addChild(fileInfo);

                    if (directory)
                    {
                        if (string.ReferenceEquals(dirName, null))
                        {
                            scan(dir.filename, fileInfo);
                        }
                        else
                        {
                            scan(dirName + "/" + dir.filename, fileInfo);
                        }
                    }

                    // Allocate the clusters after having scanned the children
                    allocateClusters(fileInfo);
                }
            }

            IList <FatFileInfo> children = parent.Children;

            if (children != null)
            {
                foreach (FatFileInfo child in children)
                {
                    computeFileName83(child, children);
                }
            }
        }
Beispiel #4
0
 public unsafe int IoGetstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* Stat)
 {
     try
     {
         var ZipEntry = ZipArchive[FileName];
         Stat->Attributes = IOFileModes.CanRead | IOFileModes.File;
         Stat->Mode = SceMode.All;
         Stat->Size = ZipEntry.OpenUncompressedStream().Length;
         return 0;
     }
     catch (KeyNotFoundException)
     {
         throw (new FileNotFoundException("Can't find file '" + FileName + "' on ZipFile"));
     }
 }
Beispiel #5
0
        private int umdIoGetstat(string umdFileName, string restFileName, SceIoStat stat)
        {
            StringBuilder      localFileName = new StringBuilder();
            IVirtualFileSystem vfs           = getUmdVfs(umdFileName, localFileName);

            if (vfs != null)
            {
                int result = vfs.ioGetstat(localFileName.ToString(), stat);
                // If the UMD file is actually a directory
                // (e.g. containing the EBOOT.PBP),
                // then stat the real file (EBOOT.PBP or DOCUMENT.DAT).
                if (!string.ReferenceEquals(restFileName, null) && restFileName.Length > 0 && result == 0)
                {
                    if ((stat.attr & 0x10) != 0)
                    {
                        result = vfs.ioGetstat(localFileName.ToString() + "/" + restFileName, stat);
                    }
                }
                return(result);
            }

            return(IO_ERROR);
        }
Beispiel #6
0
        public override int ioGetstat(string fileName, SceIoStat stat)
        {
            File file = getFile(fileName);

            if (!file.exists())
            {
                return(SceKernelErrors.ERROR_ERRNO_FILE_NOT_FOUND);
            }

            // Set attr (dir/file) and copy into mode
            int attr = 0;

            if (file.Directory)
            {
                attr |= 0x10;
            }
            if (file.File)
            {
                attr |= 0x20;
            }

            int mode = (file.canRead() ? 4 : 0) + (file.canWrite() ? 2 : 0) + (file.canExecute() ? 1 : 0);

            // Octal extend into user and group
            mode  = mode + (mode << 3) + (mode << 6);
            mode |= attr << 8;

            // Java can't see file create/access time
            ScePspDateTime ctime = ScePspDateTime.fromUnixTime(file.lastModified());
            ScePspDateTime atime = ScePspDateTime.fromUnixTime(0);
            ScePspDateTime mtime = ScePspDateTime.fromUnixTime(file.lastModified());

            stat.init(mode, attr, file.Length(), ctime, atime, mtime);

            return(0);
        }
Beispiel #7
0
        public unsafe int IoGetstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* Stat)
        {
            //Console.WriteLine(FileName);
            _IoGetstat(Iso.Root.Locate(FileName), Stat);

            return 0;
        }
Beispiel #8
0
 public override int ioChstat(string fileName, SceIoStat stat, int bits)
 {
     return(vfs.ioChstat(fileName, stat, bits));
 }
        public unsafe int IoGetstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* Stat)
        {
            var RealFileName = GetFullNormalizedAndSanitizedPath(FileName);
            //Console.WriteLine(RealFileName);

            Stat->Attributes = IOFileModes.CanExecute | IOFileModes.CanRead | IOFileModes.CanWrite;
            Stat->Mode = 0;
            Stat->Mode = SceMode.UserCanExecute | SceMode.UserCanRead | SceMode.UserCanWrite;
            Stat->Mode = SceMode.GroupCanExecute | SceMode.GroupCanRead | SceMode.GroupCanWrite;
            Stat->Mode = SceMode.OtherCanExecute | SceMode.OtherCanRead | SceMode.OtherCanWrite;

            FileSystemInfo FileSystemInfo = null;
            if (File.Exists(RealFileName))
            {
                var FileInfo = new FileInfo(RealFileName);
                FileSystemInfo = FileInfo;
                Stat->Size = FileInfo.Length;
                Stat->Mode |= SceMode.File;
                Stat->Attributes |= IOFileModes.File;
            }
            else if (Directory.Exists(RealFileName))
            {
                var DirectoryInfo = new DirectoryInfo(RealFileName);
                FileSystemInfo = DirectoryInfo;
                Stat->Mode |= SceMode.Directory;
                Stat->Attributes |= IOFileModes.Directory;
            }
            else
            {
                throw(new FileNotFoundException("Can't find file '" + RealFileName + "'"));
            }

            Stat->TimeCreation = ScePspDateTime.FromDateTime(FileSystemInfo.CreationTimeUtc);
            Stat->TimeLastAccess = ScePspDateTime.FromDateTime(FileSystemInfo.LastAccessTimeUtc);
            Stat->TimeLastModification = ScePspDateTime.FromDateTime(FileSystemInfo.LastWriteTimeUtc);

            return 0;
        }
Beispiel #10
0
 public virtual int ioChstat(string fileName, SceIoStat stat, int bits)
 {
     return(vfs.ioChstat(fileName, stat, bits));
 }
Beispiel #11
0
 public virtual int ioGetstat(string fileName, SceIoStat stat)
 {
     return(IO_ERROR);
 }
Beispiel #12
0
 public virtual int IoGetstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* Stat)
 {
     return ParentDriver.IoGetstat(HleIoDrvFileArg, FileName, Stat);
 }
Beispiel #13
0
 public virtual int IoChstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* stat, int bits)
 {
     return ParentDriver.IoChstat(HleIoDrvFileArg, FileName, stat, bits);
 }
Beispiel #14
0
        public XmbIsoVirtualFile(string umdFilename) : base(null)
        {
            this.umdFilename = umdFilename;
            umdName          = System.IO.Path.GetFileName(umdFilename);

            File cacheDirectory   = new File(CacheDirectory);
            bool createCacheFiles = !cacheDirectory.Directory;

            if (createCacheFiles)
            {
                cacheDirectory.mkdirs();
            }

            try
            {
                UmdIsoReader       iso = new UmdIsoReader(umdFilename);
                IVirtualFileSystem vfs = new UmdIsoVirtualFileSystem(iso);
                sections           = new PbpSection[umdFilenames.Length + 1];
                sections[0]        = new PbpSection();
                sections[0].index  = 0;
                sections[0].offset = 0;
                sections[0].size   = 0x28;
                sections[0].availableInContents = true;
                int       offset = 0x28;
                SceIoStat stat   = new SceIoStat();
                for (int i = 0; i < umdFilenames.Length; i++)
                {
                    PbpSection section = new PbpSection();
                    section.index       = i + 1;
                    section.offset      = offset;
                    section.umdFilename = umdFilenames[i];
                    if (vfs.ioGetstat(section.umdFilename, stat) >= 0)
                    {
                        section.size = (int)stat.size;
                        if (log.TraceEnabled)
                        {
                            log.trace(string.Format("{0}: mapping {1} at offset 0x{2:X}, size 0x{3:X}", umdFilename, umdFilenames[i], section.offset, section.size));
                        }
                    }

                    string cacheFileName = getCacheFileName(section);
                    File   cacheFile     = new File(cacheFileName);

                    // Create only cache files for PARAM.SFO and ICON0.PNG
                    if (createCacheFiles && i < 2)
                    {
                        IVirtualFile vFile = vfs.ioOpen(section.umdFilename, IoFileMgrForUser.PSP_O_RDONLY, 0);
                        if (vFile != null)
                        {
                            section.size = (int)vFile.Length();
                            sbyte[] buffer = new sbyte[section.size];
                            int     Length = vFile.ioRead(buffer, 0, buffer.Length);
                            vFile.ioClose();

                            System.IO.Stream os = new System.IO.FileStream(cacheFile, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                            os.Write(buffer, 0, Length);
                            os.Close();
                        }
                    }

                    if (cacheFile.canRead())
                    {
                        section.cacheFile = cacheFile;
                    }

                    sections[section.index] = section;
                    offset += section.size;
                }
                totalLength = offset;

                contents = new sbyte[offset];
                ByteBuffer buffer = ByteBuffer.wrap(contents).order(ByteOrder.LITTLE_ENDIAN);
                buffer.putInt(PBP.PBP_MAGIC);
                buffer.putInt(0x10000);                 // version
                for (int i = 1; i < sections.Length; i++)
                {
                    buffer.putInt(sections[i].offset);
                }
                int endSectionOffset = sections[sections.Length - 1].offset + sections[sections.Length - 1].size;
                for (int i = sections.Length; i <= 8; i++)
                {
                    buffer.putInt(endSectionOffset);
                }

                if (log.TraceEnabled)
                {
                    log.trace(string.Format("{0}: PBP header :{1}", umdFilename, Utilities.getMemoryDump(contents, sections[0].offset, sections[0].size)));
                }
                vfs.ioExit();
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("XmbIsoVirtualFile", e);
            }
            catch (IOException e)
            {
                Console.WriteLine("XmbIsoVirtualFile", e);
            }
        }
Beispiel #15
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();
        }
 public unsafe int IoGetstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* Stat)
 {
     var RealFileName = GetFullNormalizedAndSanitizedPath(FileName);
     //Console.WriteLine(RealFileName);
     var FileInfo = new FileInfo(RealFileName);
     Stat->Size = FileInfo.Length;
     return 0;
 }
Beispiel #17
0
 public unsafe int IoChstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* stat, int bits)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 public unsafe int IoGetstat(HleIoDrvFileArg HleIoDrvFileArg, string FileName, SceIoStat* Stat)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 public virtual int ioChstat(string fileName, SceIoStat stat, int bits)
 {
     return(IO_ERROR);
 }
Beispiel #20
0
 public virtual int ioGetstat(string fileName, SceIoStat stat)
 {
     return(vfs.ioGetstat(fileName, stat));
 }