Page Menu
Home
desp's stash
Search
Configure Global Search
Log In
Files
F530984
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
Fri, Jan 9, 4:55 AM (16 h, 19 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c9/b3/9f720b524409a1411f8cd0b7ba66
Attached To
rSCY Scylla
Event Timeline
Log In to Comment