public ulong GetAvailableDiskSpace(FolderUri uri) { try { Java.Lang.Process proc = Java.Lang.Runtime.GetRuntime().Exec(String.Format("df {0}", uri.AbsolutePath)); proc.WaitFor(); var resi = proc.InputStream; var rdr = new StreamReader(resi); string str = rdr.ReadToEnd(); string[] lines = str.Split('\n'); if (lines.Length < 2) { throw new InvalidOperationException("Unable to get size from shell."); } string[] entries = lines[1] .Split(' ') .Where(e => !String.IsNullOrWhiteSpace(e)) .ToArray(); string entry = entries[3]; ulong value = (ulong)Int32.Parse(entry.Substring(0, entry.Length - 1)); string unit = entry.Substring(entry.Length - 1, 1); switch (unit) { // Value is in bytes case "B": return(value); // Value is in Kbytes case "K": return(value * 1024); // Value is in Mbytes case "M": return(value * 1024 * 1024); // Value is in Gbytes case "G": return(value * 1024 * 1024 * 1024); default: throw new InvalidOperationException("Unknown size unit."); } } catch (Exception ex) { StatFs stats = new StatFs(uri.AbsolutePath); return((ulong)(stats.AvailableBlocks * stats.BlockSize)); } }
public void DeleteFolder(FolderUri uri) { if (uri.Location == StorageLocation.Bundle) { throw new InvalidOperationException("Unable to delete folder inside the bundle."); } _fileSystemPlatform.DeleteFolder(uri); }
public ulong GetAvailableDiskSpace(FolderUri uri) { ulong totalFreeSpace = 0; // Use below as suggested by Miguel de Icaza :) NSFileSystemAttributes values = NSFileManager.DefaultManager.GetFileSystemAttributes(uri.AbsolutePath); totalFreeSpace = values.FreeSize; return(totalFreeSpace); }
public FileUri[] GetFolderFiles(FolderUri uri, string searchPattern, bool recursive) { string[] filePaths = _fileSystemPlatform.GetFolderFiles(uri, searchPattern, recursive); if (filePaths == null) { return(null); } List <FileUri> fileUris = filePaths .Select(x => CreateFileUri(Path.Combine(uri.Uri, x.Replace(uri.AbsolutePath + "/", String.Empty)))) .ToList(); return(fileUris.ToArray()); }
public bool FolderExists(FolderUri uri) { return(Directory.Exists(uri.AbsolutePath)); }
public void DeleteFolder(FolderUri uri) { Directory.Delete(uri.AbsolutePath, true); }
public void CreateFolder(FolderUri uri) { Directory.CreateDirectory(uri.AbsolutePath); }
public string[] GetFolderFiles(FolderUri uri, string searchPattern, bool recursive) { return (Directory.GetFiles(uri.AbsolutePath, searchPattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)); }
public bool FolderExists(FolderUri uri) { return(_fileSystemPlatform.FolderExists(uri)); }
public ulong GetAvailableDiskSpace(FolderUri uri) { return(_fileSystemPlatform.GetAvailableDiskSpace(uri)); }