| 977 | |
| 978 | #if defined(WIN_NT) |
| 979 | void ISC_expand_share(tstring& file_name) |
| 980 | { |
| 981 | /************************************** |
| 982 | * |
| 983 | * I S C _ e x p a n d _ s h a r e |
| 984 | * |
| 985 | ************************************** |
| 986 | * |
| 987 | * Functional description |
| 988 | * Expand a file name by chasing shared disk |
| 989 | * information. |
| 990 | * |
| 991 | **************************************/ |
| 992 | // see NT reference for WNetEnumResource for the following constants |
| 993 | DWORD nument = 0xffffffff, bufSize = 16384; |
| 994 | |
| 995 | // Look for a drive letter and make sure that it corresponds to a remote disk |
| 996 | const size p = file_name.find(':'); |
| 997 | if (p != 1) |
| 998 | { |
| 999 | return; |
| 1000 | } |
| 1001 | |
| 1002 | // If RemoteFileOpenAbility = 1 doesn't expand share |
| 1003 | if (Config::getRemoteFileOpenAbility()) { |
| 1004 | return; |
| 1005 | } |
| 1006 | |
| 1007 | tstring device(file_name.substr(0, 1)); |
| 1008 | const USHORT dtype = GetDriveType((device + ":\\").c_str()); |
| 1009 | if (dtype != DRIVE_REMOTE) |
| 1010 | { |
| 1011 | return; |
| 1012 | } |
| 1013 | |
| 1014 | HANDLE handle; |
| 1015 | if (WNetOpenEnum(RESOURCE_CONNECTED, RESOURCETYPE_DISK, 0, NULL, &handle) != NO_ERROR) |
| 1016 | { |
| 1017 | return; |
| 1018 | } |
| 1019 | LPNETRESOURCE resources = (LPNETRESOURCE) gds__alloc((SLONG) bufSize); |
| 1020 | // FREE: in this routine |
| 1021 | if (!resources) // NOMEM: don't expand the filename |
| 1022 | { |
| 1023 | return; |
| 1024 | } |
| 1025 | |
| 1026 | DWORD ret = WNetEnumResource(handle, &nument, resources, &bufSize); |
| 1027 | if (ret == ERROR_MORE_DATA) |
| 1028 | { |
| 1029 | gds__free(resources); |
| 1030 | resources = (LPNETRESOURCE) gds__alloc((SLONG) bufSize); |
| 1031 | // FREE: in this routine |
| 1032 | if (!resources) // NOMEM: don't expand the filename |
| 1033 | { |
| 1034 | return; |
| 1035 | } |
| 1036 | ret = WNetEnumResource(handle, &nument, resources, &bufSize); |
no test coverage detected