Esempio n. 1
0
        private static void InitDrive(PlatformDrive drive, int dashesIncludeInName)
        {
            drive.Name = drive.AppFolderPath;
            var c = 0;
            var i = 0;

            for (i = 0; i < drive.Name.Length; i++) // extract '/data/user'
            {
                if (drive.Name[i] == '/')
                {
                    c++;
                }
                if (c == dashesIncludeInName)
                {
                    break;
                }
            }

            if (i < drive.Name.Length)
            {
                drive.Name = drive.Name.Substring(0, i);
            }

            var stats = new StatFs(drive.AppFolderPath);

            drive.BytesFree  = stats.AvailableBlocksLong * stats.BlockSizeLong;
            drive.TotalBytes = stats.BlockCountLong * stats.BlockSizeLong;
        }
        private static void InitDrive(PlatformDrive drive, int dashesIncludeInName)
        {
            drive.Name = drive.AppFolderPath;
            var c = 0;
            var i = 0;

            for (i = 0; i < drive.Name.Length; i++) // extract '/data/user'
            {
                if (drive.Name[i] == '/')
                {
                    c++;
                }
                if (c == dashesIncludeInName)
                {
                    break;
                }
            }

            if (i < drive.Name.Length)
            {
                drive.Name = drive.Name.Substring(0, i);
            }

            drive.BytesFree  = (long)NSFileManager.DefaultManager.GetFileSystemAttributes(Environment.GetFolderPath(Environment.SpecialFolder.Personal)).Size;
            drive.TotalBytes = (long)NSFileManager.DefaultManager.GetFileSystemAttributes(Environment.GetFolderPath(Environment.SpecialFolder.Personal)).FreeSize;
        }
Esempio n. 3
0
        public IEnumerable <PlatformDrive> GetDrives()
        {
            var drives = new List <PlatformDrive>();

            var drive = new PlatformDrive();

            try
            {
                drive.AppFolderPath = MainActivity.Instance.FilesDir.AbsolutePath;
                InitDrive(drive, 3);
            }
            catch { drive.Accessible = false; }

            if (!string.IsNullOrEmpty(drive.Name))
            {
                drives.Add(drive);
            }

            var ext = MainActivity.Instance.GetExternalFilesDirs(null);

            foreach (var e in ext)
            {
                if (e == null)
                {
                    continue;
                }

                drive = new PlatformDrive();

                try
                {
                    drive.AppFolderPath = e.AbsolutePath;
                    InitDrive(drive, 4);
                }
                catch { drive.Accessible = false; }

                if (!string.IsNullOrEmpty(drive.Name))
                {
                    drives.Add(drive);
                }
            }

            return(drives);
        }
        public IEnumerable <PlatformDrive> GetDrives()
        {
            var drives = new List <PlatformDrive>();

            var drive = new PlatformDrive();

            try
            {
                drive.AppFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "..", "tmp");
                InitDrive(drive, 3);
            }
            catch { drive.Accessible = false; }

            if (!string.IsNullOrEmpty(drive.Name))
            {
                drives.Add(drive);
            }

            return(drives);
        }