Commits

Ikey Doherty committed 0cc4dca

Added SSD detection

Comments (0)

Files changed (2)

src/core/disk/disks.vala

 
    // Total disk size
    public uint64 size { protected set; public get; }
+
+   // Is this an SSD device ?
+   public bool ssd { protected set; public get; }
+
    public Disk (Ped.Disk parent) {
 	this.path = parent.dev.path;
 
 	};
 
 	this.partitions.sort(partcmp);
+
+	// Attempt to work out if this is an ssd
+	this.ssd = false;
+	var node = path.replace("/dev/","");
+	var testSSD = "/sys/block/%s/queue/rotational".printf(node);
+	if (FileUtils.test (testSSD, FileTest.EXISTS)) {
+		File rotational = File.new_for_path (testSSD);
+		try {
+			var dis = new DataInputStream (rotational.read(null));
+			var line = dis.read_line(null,null);
+			if (line.strip() == "0") {
+				this.ssd = true;
+			}
+		} catch (GLib.Error e) { // doesn't matter
+		}
+	}
    }
 } // End Disk definition
 

src/widgets/diskchooser/diskchooser.vala

 	this.pack_start (image, false, false, 10);
 	//var disk_info = "<big>%s (%s)</big>\n<small>%s</small>".printf(disk.model, misc.format_size(disk.size), disk.type);
 	var disk_info = "<big>%s (%s)</big>".printf (disk.model, format_size (disk.size) );
-	label = new Gtk.Label ("<span color=\"%s\">%s</span>".printf(fgColor, disk_info));
+
+	var disp_label = "<span color=\"%s\">%s</span>".printf(fgColor, disk_info);
+	// Make sure user knows its SSD
+	if (disk.ssd) {
+		disp_label = "<span color=\"%s\">%s (SSD)</span>".printf(fgColor, disk_info);
+	}
+
+
+
+
+	label = new Gtk.Label (disp_label);
 	label.use_markup = true;
 
 	this.pack_start (label, false, false, 0);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.