| 1516 | |
| 1517 | #ifdef WIN_NT |
| 1518 | static void share_name_from_resource(tstring& file_name, LPNETRESOURCE resource) |
| 1519 | { |
| 1520 | /************************************** |
| 1521 | * |
| 1522 | * s h a r e _ n a m e _ f r o m _ r e s o u r c e |
| 1523 | * |
| 1524 | ************************************** |
| 1525 | * |
| 1526 | * Functional description |
| 1527 | * if the shared drive is Windows or Novell prosess the |
| 1528 | * name appropriately, otherwise just return the remote name |
| 1529 | * expects filename to be of the form DRIVE_LETTER:\PATH |
| 1530 | * returns new filename in expanded_name; shouldn't touch filename |
| 1531 | * |
| 1532 | **************************************/ |
| 1533 | tstring expanded_name = resource->lpRemoteName; |
| 1534 | |
| 1535 | const TEXT* mwn = "Microsoft Windows Network"; |
| 1536 | if (!strnicmp(resource->lpProvider, mwn, strlen(mwn))) |
| 1537 | { |
| 1538 | /* If the shared drive is via Windows |
| 1539 | package it up so that resolution of the share name can |
| 1540 | occur on the remote machine. The name |
| 1541 | that will be transmitted to the remote machine will |
| 1542 | have the form \\REMOTE_NODE\!SHARE_POINT!\FILENAME */ |
| 1543 | |
| 1544 | size p = expanded_name.find('\\', 2); |
| 1545 | expanded_name.insert(++p, 1, '!'); |
| 1546 | expanded_name += '!'; |
| 1547 | file_name.replace(0, 2, expanded_name); |
| 1548 | } |
| 1549 | else |
| 1550 | { |
| 1551 | // we're guessing that it might be an NFS shared drive |
| 1552 | |
| 1553 | iter q = expanded_name.end() - 1; |
| 1554 | if (*q == '\\' || *q == '/') // chop off any trailing \ or / |
| 1555 | { |
| 1556 | expanded_name.erase(q); |
| 1557 | } |
| 1558 | file_name.replace(0, 2, expanded_name); |
| 1559 | |
| 1560 | /* If the expanded filename doesn't begin with a node name of the form |
| 1561 | \\NODE and it contains a ':', then it's probably an NFS mounted drive. |
| 1562 | Therefore we must convert any back slashes to forward slashes. */ |
| 1563 | |
| 1564 | if ((file_name[0] != '\\' || file_name[1] != '\\') && (file_name.find(INET_FLAG) != npos)) |
| 1565 | { |
| 1566 | for (q = file_name.begin(); q < file_name.end(); ++q) |
| 1567 | { |
| 1568 | if (*q == '\\') |
| 1569 | { |
| 1570 | *q = '/'; |
| 1571 | } |
| 1572 | } |
| 1573 | } |
| 1574 | } |
| 1575 | } |