Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F554751
DeviceNameResolver.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
DeviceNameResolver.cpp
View Options
#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
Details
Attached
Mime Type
text/x-c
Expires
Tue, Feb 10, 10:39 PM (1 d, 14 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
65/0d/2709f461888e2b31e05a0babfd69
Attached To
rSCY Scylla
Event Timeline
Log In to Comment