Detect when a USB device is connected in C
I am new to C and am trying to write a program that syncs files on my computer to a USB device. It currently works my me cd'ing to the directory that the device mounts to and typing "myprog init" which creates a .myprog file. The idea then is that when a USB device is connected my program checks for the .myprog file, if it finds it then it syncs. Problem is that I can't figure out how to detect when a new USB device is connected.
I am writing the program for Linux (I'm using Ubuntu 9.04) and using GCC.
Thanks for any help :)
Look into udev documentation for this (writing udev rules).
Also have a look at this stackoverflow thread.
链接地址: http://www.djcxy.com/p/42780.html上一篇: 将Google Maps API密钥包含在开源项目中?
下一篇: 检测USB设备连接到C时