示例#1
0
        public Errno GetAttributes(string path, out FileAttributes attributes)
        {
            attributes = new FileAttributes();
            if (!mounted)
            {
                return(Errno.AccessDenied);
            }

            Errno err = Stat(path, out FileEntryInfo stat);

            if (err != Errno.NoError)
            {
                return(err);
            }

            attributes = stat.Attributes;

            return(Errno.NoError);
        }
示例#2
0
        public Errno GetAttributes(string path, out FileAttributes attributes)
        {
            attributes = new FileAttributes();
            if (!mounted)
            {
                return(Errno.AccessDenied);
            }

            string[] pathElements = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            if (pathElements.Length != 1)
            {
                return(Errno.NotSupported);
            }

            string filename = pathElements[0].ToUpperInvariant();

            if (!fileCache.ContainsKey(filename))
            {
                return(Errno.NoSuchFile);
            }

            attributes  = FileAttributes.Extents;
            attributes |= FileAttributes.File;
            if (lockedFiles.Contains(filename))
            {
                attributes |= FileAttributes.ReadOnly;
            }

            if (debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
                          string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
                          string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
            {
                attributes |= FileAttributes.System;
            }

            return(Errno.NoError);
        }
示例#3
0
        public Errno GetAttributes(string path, out FileAttributes attributes)
        {
            attributes = new FileAttributes();
            if (!mounted)
            {
                return(Errno.AccessDenied);
            }

            string[] pathElements = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            if (pathElements.Length != 1)
            {
                return(Errno.NotSupported);
            }

            path = pathElements[0];

            if (!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId))
            {
                return(Errno.NoSuchFile);
            }

            if (!idToEntry.TryGetValue(fileId, out MFS_FileEntry entry))
            {
                return(Errno.NoSuchFile);
            }

            MFS_FinderFlags fdFlags = (MFS_FinderFlags)BigEndianBitConverter.ToUInt16(entry.flUsrWds, 0x08);

            if (fdFlags.HasFlag(MFS_FinderFlags.kIsAlias))
            {
                attributes |= FileAttributes.Alias;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kHasBundle))
            {
                attributes |= FileAttributes.Bundle;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kHasBeenInited))
            {
                attributes |= FileAttributes.HasBeenInited;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kHasCustomIcon))
            {
                attributes |= FileAttributes.HasCustomIcon;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kHasNoINITs))
            {
                attributes |= FileAttributes.HasNoINITs;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kIsInvisible))
            {
                attributes |= FileAttributes.Hidden;
            }
            if (entry.flFlags.HasFlag(MFS_FileFlags.Locked))
            {
                attributes |= FileAttributes.Immutable;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kIsOnDesk))
            {
                attributes |= FileAttributes.IsOnDesk;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kIsShared))
            {
                attributes |= FileAttributes.Shared;
            }
            if (fdFlags.HasFlag(MFS_FinderFlags.kIsStationery))
            {
                attributes |= FileAttributes.Stationery;
            }

            if (!attributes.HasFlag(FileAttributes.Alias) && !attributes.HasFlag(FileAttributes.Bundle) &&
                !attributes.HasFlag(FileAttributes.Stationery))
            {
                attributes |= FileAttributes.File;
            }

            attributes |= FileAttributes.BlockUnits;

            return(Errno.NoError);
        }