Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to chek if it is enough memory on USB stick

Status
Not open for further replies.

koschka

Newbie level 4
Newbie level 4
Joined
Jan 23, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
I am using libusb library. I got to work to check the program if a USB stick is detected to. That I have to find out is if there enough memory on USB stick. Does anyone have an idea how to do it. Are in this libusb library parameters which say how much memory does USb stick has total and how much in used?
 

Open My Computer
Point mouse pointer on memory flash icon and wait 1 second data will show




Open My Computer,
find usb memory icon,
point on that icon,
right click on mouse
Click on Properties
General tab shows needed informations
 

Open My Computer
Point mouse pointer on memory flash icon and wait 1 second data will show




Open My Computer,
find usb memory icon,
point on that icon,
right click on mouse
Click on Properties
General tab shows needed informations

I have to check it in C++ using libusb library.

---------- Post added at 14:45 ---------- Previous post was at 14:45 ----------

in Windows XP
 

An memory stick will be installed as mass storage device and handled by the OS file system, unless you block the installation somehow. It's accessible by generic C file functions and additional Windows SDK functions.

What do you want to do with libusb? Read raw sectors, decode the boot block and FAT to determine the free storage capacity?
 

with libusb I detected all USB devices connected to my computer. I used libusb_interface_descriptor to sort all devices which are equal LIBUSB_CLASS_MASS_STORAGE. So now I have only USB sticks connected. My problem I have to check out if some Bytes(for example 500KByte) fit on this USB stick. I have no idea how to check it. I know how to check it on my computer using Properties of USB but how to detect it by using coding I don't know.
 

How do you write to the memory stick after determing sufficient capacity? Isn't it by file functions?

If you don't access it as a removable disk (using file functions), you have to walk through the mass storage and file system layers in your code.
 

use the win32 api function,

GetDiskFreeSpaceEx(....)

to know about the space from your c program.
 

I don't have to write. I just have to determin if some Bytes fit on this USB stick,nothing more.

---------- Post added at 15:28 ---------- Previous post was at 15:16 ----------

and by using libusb library can't I detect the free space on USB stick somehow?
 

by using libusb library can't I detect the free space on USB stick somehow?
I already mentioned how it works:
- read master boot sector and possibly logical drives boot sectors
- determine the file system (FAT16/FAT32) from the boot sector entries
- read all FAT sectors and calculate free space
 

I already mentioned how it works:
- read master boot sector and possibly logical drives boot sectors
- determine the file system (FAT16/FAT32) from the boot sector entries
- read all FAT sectors and calculate free space

tnx for your help, I will try to use the GetDiskFreeSpaceEx(....) method.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top