 Hey, everybody, it's Brian, and in this video, we're going to talk about the Q storage info class. Now, what is this thing? Well, it's our introduction into the file system. Doesn't matter if you're on Windows, Mac, Linux, iPhone, Android, whatever, Raspberry Pi, some weird embedded thing, virtually everything has some sort of storage. Now, this provides information about the currently mounted storage and drives. Notice I slowed down and highlighted all that. There's a few key takeaways here. It's mounted. What does that mean? Storage and drives. Notice it's not storage or just the word drives, they're two different things. Well, this is a Linux virtual machine, and it's actually just very basic, but it has a folder structure. These folders live in the file system. If I go in here and let me just minimize this to get rid of some clutter here, type in the word disk, and go to our disk viewer. You can see I have a hard drive and a storage device, which is a CD slash DVD drive, and it's not mounted. The hard drive is mounted. Mounted just simply means it's available to the operating system. Now, if it's not mounted, it means it's not available. You see our CD has no media. This is probably going to be a short video because, well, this is a boring class, and I mean that as a compliment. It's dead simple to work with. We don't need to have some lengthy five hour conversation. It just does what it says it does. Now, I also wanted to just really quickly pause and say, hey, if you're out in the Voidrums Facebook group, go ahead and jump in and congratulate Qt. That's actually Qt, the software company. They joined our group as of this morning officially, and they are now a part of the group. So if you're in there, go ahead and do the happy dance. Otherwise, I hope you join us and we'll see you there. Okay. I'm just going to love it with you. This video is going to be ridiculously short because this class is very, very simple. It doesn't matter what operating system you're on. Just go ahead and highlight it. Hit F1 on the keyboard, brings up the help file. You can see this is a pretty simple little class here. It doesn't have a whole lot of meat to it, and you guessed it, you can, as with most Qt documentation, literally just shamelessly copy and paste right out of the help file, and it just works. That's what I love about Qt. So all right, let's just go ahead and we're going to get the root of the operating system. If you're on Linux, you probably know what that means. It's just a slash. If you're on Windows, the concept of root may be a little foreign to you, but it's similar or usually is the C drive. However, Windows can have like CD and so on. You can have multiple drives, but your root operating system file system is C drive, usually on Windows. I have to say usually, because Windows is just one of those really dumb OSes sometimes where you can just do some things, even though you shouldn't. All right, so we're going to go ahead and just say QStorageInfo and we want to get root. That's it. It's really that simple. So now that we have the root, we want to be able to display the information about that. Now note, root is always mounted. I have to kind of hesitate when I say that because some bizarre operating systems you can have the root not mounted and they just have a bootloader. But anyways, let's take a look at how to display the root information. Now that we've gotten the root of the operating system here and you notice how I had a lot of caveats and hesitations because every operating system does treat this a little bit differently, but Qt makes it ridiculously simple. We're going to get the details and this is where I'm just going to grab something off the screen and save about 200,000 hours of me trying to type this out. So all we're going to do is we have a function called display which is going to take our QStorageInfo along with some sort of title so we know what we're displaying and we're going to display the name, the display name, is it root? And I'm going to slow down a little bit, kind of go, what are these things? You can always just highlight it, F1 on the screen takes you right to the help file. So for example, name is the human readable name of the file system, usually called a label. And this is where people get confused. They think, well, shouldn't the name be your operating system like Mac or Windows or Linux? No, remember, this is a hard drive we're talking about or a storage device. I have to say or because they can be two different things. Then you have a friendly display name then is root. Again, if you're not familiar with the concept of root, this may be a little mind-boggling, but in Linux, it's just simply slash. In Windows, it would be like your C drive, it's the root operating system. Then you get the root path. And again, this really talks about, you know, if you're on a Linux or Linux variant, it's going to be a slash, otherwise it would probably be your C drive in Windows. And then you can have your actual file system types, whether or not it's read only. This is a big one because not all file systems are writable. For example, a DVD, you may not be able to write to that. And then ready, this is another one because guess what? Sometimes it may be mounting but not ready to work with yet. So you get some real oddities when you start working with hardware. And then I actually just shamelessly copied this right out of the Q help file where we get the size, the available and the free bytes and we're getting that in megabytes. Feel free to format this however you want, but you get the bytes total, bytes available and bytes free. And because this isn't bytes, you have to do a little bit of math to really make it the way you want it. So we're just going to take this function here and we're going to say display. And we want to display our root. And I'm going to give it a title. I'm going to call it root. Go ahead and save this and let's run it. And drumroll. So this is our root here and this is going to look a slightly different on your screen depending on what you're running on. So for example, I'm on a Linux machine, so it's just going to have a slash. If you're on Windows, it's probably going to say like you're a C drive. This is my root. See how it's true. And then we have our path. And then we have the actual device name. This is actually pretty awesome. And then the file system type, EXT4, you may see NTFS if you're on Windows. This is not read only meaning I can write to it. Of course it is ready. And then I get the size available and free. I should really expand this drive. Next, we're going to get all of the mounted devices. And this is going to take a little bit of background work on my part because this virtual machine only has one hard drive. So I'm going to actually minimize Qt Creator. And I'm going to pull up virtual box. This is the actual hypervisor that's running this virtual machine. And I'm just going to go into settings and then I'm going to go to storage. And I'm going to take this DVD here and I'm going to put an ISO image on. I'm just going to put Linux Mint 20.1-Cinnamon.64 bit ISO. It doesn't really matter. I just want something mounted here. I'm going to put that in there, hit OK, and then go and you'll see it mount right here. There we go. So when I go into the disk, you should see that it is actually mounted now. And I have multiple things that I can work with here. All right, back in the IDE. Now I'm going to warn you I've done this little section about 10 times because it's springtime here in Michigan. And I feel like I'm going to sneeze at a moment's notice. I keep having to stop the recording and do it over again. We're just going to make a Q list, a Q storage infos. I'm going to call this Devices. See, I feel like I'm going to sneeze again. We're going to push forward and see if I can finish this one. And we're going to say mounted volumes. Notice the wording. This is not a device. It's a volume. And if I highlight this and hit F1, you can also see that returns a list of Q storage info objects that corresponds with the list of currently mounted file systems plural. So have a little respect for what you're doing here. There are multiple operating systems. Each operating system has multiple file systems. Each file system is different. So not all the information is going to work, meaning you can expect things to act differently. Now, what Qt is done with Q storage info is made kind of a, I want to call it a high level generic pane of glass for you to look at everything on. So I'm going to say for each. He's using the term generic because this is anything but. I'm going to look at each device in our Devices. And then I'm going to beg, borrow and steal. This guy right here. And let's just do this. And I intentionally made this a bad example to just really highlight something. We're going to use the device name. And if I highlight this, it just says returns the human readable name of the file system, usually called label. But if you dive into the help file, you'll say, or I should say you'll see, not all file systems support this feature. Meaning you're going to get different results on different operating systems. And spoiler alert on Linux for treating the volumes label requires you Dev to be present. Point being, you're going to have to treat this slightly different. And this is something I wanted to illustrate. Don't just automatically assume the information is going to be present just because it's in part of the class. Now, the other thing I wanted to highlight is, if I look at the disks, and I'm doing this all intentionally before I run, there's really only two disks. There's our hard disk, and then there's the DVD. But if you look at this hard disk, you see it's got all these little things in here. These are partitions, right? So we have this partition one, two, five, and free space. Ooh, I've got one mega free space. I need to figure out how to use that. Anyways, point being, each one of these is different. So we have SDA2, SDA1, and then SDA5 and things like that. Keep that in mind when we run this, because if you run this and you expect to see only two things, boy are you in for a shock. We're going to see all the mounted volumes. And in my little virtual machine, there's a lot now. All right, so we have our root, and remember we manually put that label in there. So there's no name. And again, no name, because I'm on Linux. You may see something different. Like Windows, this may say like C drive or, you know, or my computer or something like that. It's going to say display slash run. And then we've got the display is just slash. So this is our actual root. You can see root true. But if I go to like slash run lock, root is false because this is not the root of our operating system. And this is a temp file system where our root on this Linux machine is EXT4. So that's the major takeaway here. You're going to see everything the operating system sees. And this can get a little confusing and be a bit information overload. So you got to kind of hunt and pick for what you want. And of course, there's our DVD right there. I hope you enjoyed this video. You can find the source code out on github.com. If you need additional help, myself and thousands of other developers are hanging out in the Voidromes Facebook group. This is a large group with lots of developers. And we talk about everything technology related, not just the technology that you just watched. And if you want official training, I do develop courses out on udemy.com. This is official classroom style training. If you go out there and the course you're looking for is just simply not there, drop me a note. I'm either working on it or I will actually develop it. I will put a link down below for all three of those. And as always, help me help you smash that like and subscribe button. The more popular these videos become, the more I'll create and publish out on YouTube. Thank you for watching.