Merge pull request #571 from mattmccutchen/master
getDevice: Do not read a dirent after calling closedir.
This commit is contained in:
@@ -13,17 +13,21 @@
|
|||||||
|
|
||||||
RString getDevice(RString inputDir, RString type)
|
RString getDevice(RString inputDir, RString type)
|
||||||
{
|
{
|
||||||
|
RString result = "";
|
||||||
DIR* dir = opendir( inputDir.c_str() );
|
DIR* dir = opendir( inputDir.c_str() );
|
||||||
if(dir == NULL)
|
if(dir == NULL)
|
||||||
{ LOG->Warn("LinuxInputManager: Couldn't open %s: %s.", inputDir.c_str(), strerror(errno) ); return ""; }
|
{ LOG->Warn("LinuxInputManager: Couldn't open %s: %s.", inputDir.c_str(), strerror(errno) ); return ""; }
|
||||||
|
|
||||||
struct dirent* d;
|
struct dirent* d;
|
||||||
while( ( d = readdir(dir) ) != NULL)
|
while( ( d = readdir(dir) ) != NULL)
|
||||||
if( strncmp( type.c_str(), d->d_name, type.size() ) == 0) break;
|
if( strncmp( type.c_str(), d->d_name, type.size() ) == 0)
|
||||||
|
{
|
||||||
|
result = RString("/dev/input/") + d->d_name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
if( d == NULL ) return "";
|
return result;
|
||||||
return RString("/dev/input/") + d->d_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinuxInputManager::LinuxInputManager()
|
LinuxInputManager::LinuxInputManager()
|
||||||
|
|||||||
Reference in New Issue
Block a user