Page MenuHomedesp's stash

DeviceNameResolver.cpp
No OneTemporary

DeviceNameResolver.cpp

#include "DeviceNameResolver.h"
DeviceNameResolver::DeviceNameResolver()
{
initDeviceNameList();
}
DeviceNameResolver::~DeviceNameResolver()
{
deviceNameList.clear();
}
void DeviceNameResolver::initDeviceNameList()
{
TCHAR shortName[3] = {0};
TCHAR longName[MAX_PATH] = {0};
HardDisk hardDisk;
shortName[1] = L':';
deviceNameList.reserve(3);
for ( TCHAR shortD = TEXT('a'); shortD < TEXT('z'); shortD++ )
{
shortName[0] = shortD;
if (QueryDosDevice( shortName, longName, MAX_PATH ) > 0)
{
hardDisk.shortName[0] = _totupper(shortD);
hardDisk.shortName[1] = TEXT(':');
hardDisk.shortName[2] = 0;
hardDisk.longNameLength = _tcslen(longName);
_tcscpy_s(hardDisk.longName, longName);
deviceNameList.push_back(hardDisk);
}
}
}
bool DeviceNameResolver::resolveDeviceLongNameToShort( WCHAR * sourcePath, WCHAR * targetPath )
{
for (unsigned int i = 0; i < deviceNameList.size(); i++)
{
if (!_tcsnicmp(deviceNameList[i].longName, sourcePath, deviceNameList[i].longNameLength))
{
_tcscpy_s(targetPath, MAX_PATH, deviceNameList[i].shortName);
_tcscat_s(targetPath, MAX_PATH, sourcePath + deviceNameList[i].longNameLength);
return true;
}
}
return false;
}

File Metadata

Mime Type
text/x-c
Expires
Fri, Jan 9, 4:55 AM (16 h, 19 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c9/b3/9f720b524409a1411f8cd0b7ba66

Event Timeline