Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F607711
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
Thu, Apr 2, 5:07 PM (1 d, 8 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
67/ff/721b273f53d1a380ba5ca3770763
Attached To
rSCY Scylla
Event Timeline
Log In to Comment