예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private pspsharp.filesystems.umdiso.iso9660.Iso9660File getFileEntry(String filePath) throws java.io.IOException, java.io.FileNotFoundException
        private Iso9660File getFileEntry(string filePath)
        {
            Iso9660File info;

            info = fileCache[filePath];
            if (info != null)
            {
                return(info);
            }

            int parentDirectoryIndex = filePath.LastIndexOf('/');

            if (parentDirectoryIndex >= 0)
            {
                string           parentDirectory = filePath.Substring(0, parentDirectoryIndex);
                Iso9660Directory dir             = dirCache[parentDirectory];
                if (dir != null)
                {
                    int index = dir.getFileIndex(filePath.Substring(parentDirectoryIndex + 1));
                    info = dir.getEntryByIndex(index);
                    if (info != null)
                    {
                        fileCache[filePath] = info;
                        return(info);
                    }
                }
            }

            Iso9660Directory dir = new Iso9660Handler(this);

            string[] path = filePath.Split("[\\/]", true);

            // First convert the path to a canonical path by removing all the
            // occurrences of "." and "..".
            int pathLength = path.Length;

            for (int i = 0; i < pathLength;)
            {
                if (path[i].Equals("."))
                {
                    // Remove "."
                    pathLength = removePath(path, i, pathLength);
                }
                else if (path[i].Equals(".."))
                {
                    // Remove ".." and its parent
                    pathLength = removePath(path, i, pathLength);
                    pathLength = removePath(path, i - 1, pathLength);
                }
                else
                {
                    i++;
                }
            }

            // walk through the canonical path
            for (int i = 0; i < pathLength;)
            {
                int index = dir.getFileIndex(path[i]);

                info = dir.getEntryByIndex(index);

                if (isDirectory(info))
                {
                    dir = new Iso9660Directory(this, info.LBA, info.Size);
                    StringBuilder dirPath = new StringBuilder(path[0]);
                    for (int j = 1; j <= i; j++)
                    {
                        dirPath.Append("/").Append(path[j]);
                    }
                    dirCache[dirPath.ToString()] = dir;
                }
                i++;
            }

            if (info != null)
            {
                fileCache[filePath] = info;
            }

            return(info);
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public Iso9660File getEntryByIndex(int index) throws ArrayIndexOutOfBoundsException
        public override Iso9660File getEntryByIndex(int index)
        {
            return(internalDir.getEntryByIndex(index));
        }