Blame toonz/sources/toonzfarm/tfarmclient/util.cpp
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "util.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#include <windows.h></windows.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
string convertToUncString(const TFilePath &fp) {
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DWORD cbBuff = 1024; // Size of Buffer
|
|
Shinya Kitaoka |
120a6e |
char szBuff[1024]; // Buffer to receive information
|
|
Shinya Kitaoka |
120a6e |
REMOTE_NAME_INFO *prni = (REMOTE_NAME_INFO *)&szBuff;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Pointers to head of buffer
|
|
Shinya Kitaoka |
120a6e |
UNIVERSAL_NAME_INFO *puni = (UNIVERSAL_NAME_INFO *)&szBuff;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DWORD dwResult =
|
|
Shinya Kitaoka |
120a6e |
WNetGetUniversalName(toString(fp.getWideString()).c_str(),
|
|
Shinya Kitaoka |
120a6e |
UNIVERSAL_NAME_INFO_LEVEL, (LPVOID)&szBuff, &cbBuff);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
switch (dwResult) {
|
|
Shinya Kitaoka |
120a6e |
case NO_ERROR:
|
|
Shinya Kitaoka |
120a6e |
return puni->lpUniversalName;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case ERROR_NOT_CONNECTED:
|
|
Shinya Kitaoka |
120a6e |
// The network connection does not exists.
|
|
Shinya Kitaoka |
120a6e |
throw TException("The path specified doesn't refer to a shared folder");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case ERROR_CONNECTION_UNAVAIL:
|
|
Shinya Kitaoka |
120a6e |
// The device is not currently connected,
|
|
Shinya Kitaoka |
120a6e |
// but it is a persistent connection.
|
|
Shinya Kitaoka |
120a6e |
throw TException("The shared folder is not currently connected");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
throw TException("Cannot convert the path specified to UNC");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
return fp.getFullPath().c_str();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|