예제 #1
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);
        }
예제 #2
0
파일: File.cs 프로젝트: morefun0302/Aaru
        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);
        }
예제 #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 FileEntry entry))
            {
                return(Errno.NoSuchFile);
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias))
            {
                attributes |= FileAttributes.Alias;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBundle))
            {
                attributes |= FileAttributes.Bundle;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasBeenInited))
            {
                attributes |= FileAttributes.HasBeenInited;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasCustomIcon))
            {
                attributes |= FileAttributes.HasCustomIcon;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kHasNoINITs))
            {
                attributes |= FileAttributes.HasNoINITs;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsInvisible))
            {
                attributes |= FileAttributes.Hidden;
            }

            if (entry.flFlags.HasFlag(FileFlags.Locked))
            {
                attributes |= FileAttributes.Immutable;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsOnDesk))
            {
                attributes |= FileAttributes.IsOnDesk;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsShared))
            {
                attributes |= FileAttributes.Shared;
            }

            if (entry.flUsrWds.fdFlags.HasFlag(AppleCommon.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);
        }