Exemplo n.º 1
0
        public bool CreateDirectory(string path, bool createIntermediates, NSFileAttributes attributes)
        {
            NSError error;
            var     dict = attributes == null ? null : attributes.ToDictionary();

            return(CreateDirectory(path, createIntermediates, dict, out error));
        }
Exemplo n.º 2
0
 public bool SetAttributes(NSFileAttributes attributes, string path, out NSError error)
 {
     if (attributes == null)
     {
         throw new ArgumentNullException("attributes");
     }
     return(SetAttributes(attributes.ToDictionary(), path, out error));
 }
Exemplo n.º 3
0
        internal static NSFileSystemAttributes FromDictionary(NSDictionary dict)
        {
            if (dict == null)
            {
                return(null);
            }
            var ret = new NSFileSystemAttributes(dict);

            ret.Size      = NSFileAttributes.fetch_ulong(dict, NSFileManager.SystemSize) ?? 0;
            ret.FreeSize  = NSFileAttributes.fetch_ulong(dict, NSFileManager.SystemFreeSize) ?? 0;
            ret.Nodes     = NSFileAttributes.fetch_long(dict, NSFileManager.SystemNodes) ?? 0;
            ret.FreeNodes = NSFileAttributes.fetch_long(dict, NSFileManager.SystemFreeNodes) ?? 0;
            ret.Number    = NSFileAttributes.fetch_uint(dict, NSFileManager.SystemFreeNodes) ?? 0;

            return(ret);
        }
Exemplo n.º 4
0
        public NSFileAttributes GetAttributes(string path)
        {
            NSError error;

            return(NSFileAttributes.FromDictionary(_GetAttributes(path, out error)));
        }
Exemplo n.º 5
0
        public bool CreateFile(string path, NSData data, NSFileAttributes attributes)
        {
            var dict = attributes == null ? null : attributes.ToDictionary();

            return(CreateFile(path, data, dict));
        }
Exemplo n.º 6
0
        public static NSFileAttributes FromDictionary(NSDictionary dict)
        {
            if (dict == null)
            {
                return(null);
            }
            var ret = new NSFileAttributes();

            ret.AppendOnly = fetch_bool(dict, NSFileManager.AppendOnly);
            ret.Busy       = fetch_bool(dict, NSFileManager.Busy);
#if XAMCORE_2_0
            ret.ExtensionHidden = fetch_bool(dict, NSFileManager.ExtensionHidden);
#else
            ret.FileExtensionHidden = fetch_bool(dict, NSFileManager.ExtensionHidden);
#endif
            ret.CreationDate          = dict.ObjectForKey(NSFileManager.CreationDate) as NSDate;
            ret.OwnerAccountName      = dict.ObjectForKey(NSFileManager.OwnerAccountName) as NSString;
            ret.GroupOwnerAccountName = dict.ObjectForKey(NSFileManager.GroupOwnerAccountName) as NSString;
            ret.SystemNumber          = fetch_nint(dict, NSFileManager.SystemNumber);
            ret.DeviceIdentifier      = fetch_nuint(dict, NSFileManager.DeviceIdentifier);
#if XAMCORE_2_0
            ret.GroupOwnerAccountID = fetch_nuint(dict, NSFileManager.GroupOwnerAccountID);
#else
            ret.FileGroupOwnerAccountID = fetch_nuint(dict, NSFileManager.GroupOwnerAccountID);
#endif
            ret.Immutable        = fetch_bool(dict, NSFileManager.Immutable);
            ret.ModificationDate = dict.ObjectForKey(NSFileManager.ModificationDate) as NSDate;
#if XAMCORE_2_0
            ret.OwnerAccountID = fetch_nuint(dict, NSFileManager.OwnerAccountID);
#else
            ret.FileOwnerAccountID = fetch_nuint(dict, NSFileManager.OwnerAccountID);
#endif
            ret.HfsCreatorCode = fetch_nuint(dict, NSFileManager.HfsCreatorCode);
            ret.HfsTypeCode    = fetch_nuint(dict, NSFileManager.HfsTypeCode);
#if XAMCORE_2_0
            ret.PosixPermissions = fetch_short(dict, NSFileManager.PosixPermissions);
#else
            ret.PosixPermissions = (uint?)fetch_short(dict, NSFileManager.PosixPermissions);
#endif
#if XAMCORE_2_0
            ret.ReferenceCount   = fetch_nuint(dict, NSFileManager.ReferenceCount);
            ret.SystemFileNumber = fetch_nuint(dict, NSFileManager.SystemFileNumber);
            ret.Size             = fetch_ulong(dict, NSFileManager.Size);
#else
            ret.FileReferenceCount   = fetch_nuint(dict, NSFileManager.ReferenceCount);
            ret.FileSystemFileNumber = fetch_nuint(dict, NSFileManager.SystemFileNumber);
            ret.FileSize             = fetch_ulong(dict, NSFileManager.Size);
#endif

            NSString name;

            name = dict.ObjectForKey(NSFileManager.NSFileType) as NSString;
            if (name != null)
            {
                NSFileType?type = null;

                if (name == NSFileManager.TypeDirectory)
                {
                    type = NSFileType.Directory;
                }
                else if (name == NSFileManager.TypeRegular)
                {
                    type = NSFileType.Regular;
                }
                else if (name == NSFileManager.TypeSymbolicLink)
                {
                    type = NSFileType.SymbolicLink;
                }
                else if (name == NSFileManager.TypeSocket)
                {
                    type = NSFileType.Socket;
                }
                else if (name == NSFileManager.TypeCharacterSpecial)
                {
                    type = NSFileType.CharacterSpecial;
                }
                else if (name == NSFileManager.TypeBlockSpecial)
                {
                    type = NSFileType.BlockSpecial;
                }
                else if (name == NSFileManager.TypeUnknown)
                {
                    type = NSFileType.Unknown;
                }

#if XAMCORE_2_0
                ret.Type = type;
#else
                ret.FileType = type;
#endif
            }

#if !MONOMAC
            name = dict.ObjectForKey(NSFileManager.FileProtectionKey) as NSString;
            if (name != null)
            {
                NSFileProtection?protection = null;

                if (name == NSFileManager.FileProtectionNone)
                {
                    protection = NSFileProtection.None;
                }
                else if (name == NSFileManager.FileProtectionComplete)
                {
                    protection = NSFileProtection.Complete;
                }
                else if (name == NSFileManager.FileProtectionCompleteUnlessOpen)
                {
                    protection = NSFileProtection.CompleteUnlessOpen;
                }
                else if (name == NSFileManager.FileProtectionCompleteUntilFirstUserAuthentication)
                {
                    protection = NSFileProtection.CompleteUntilFirstUserAuthentication;
                }

                ret.ProtectionKey = protection;
            }
#endif
            return(ret);
        }
Exemplo n.º 7
0
 public NSFileAttributes ToFileAttributes()
 {
     return(NSFileAttributes.FromDictionary(this));
 }