|
@@ -4102,24 +4102,40 @@ IFile * createIFile(const char * filename)
|
|
|
IFile *ret = createContainedIFileByHook(filename);
|
|
|
if (ret)
|
|
|
return ret;
|
|
|
- bool linremote=(memcmp(filename,"//",2)==0);
|
|
|
- if (!linremote&&(memcmp(filename,"\\\\",2)!=0)) // see if remote looking
|
|
|
- return new CFile(filename);
|
|
|
+
|
|
|
RemoteFilename rfn;
|
|
|
rfn.setRemotePath(filename);
|
|
|
+
|
|
|
if (rfn.isNull())
|
|
|
throw MakeStringException(-1, "CreateIFile cannot resolve %s", filename);
|
|
|
- if (rfn.isLocal()) { // ignore dafilesrv request if local and standard port
|
|
|
+
|
|
|
+ ret = createIFileByHook(rfn); // use daliservix in preference
|
|
|
+ if (ret)
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ // NB: This is forcing OS path access if not a url beginning '//' or '\\'
|
|
|
+ bool linremote=(memcmp(filename,"//",2)==0);
|
|
|
+ if (!linremote&&(memcmp(filename,"\\\\",2)!=0)) // see if remote looking
|
|
|
+ return new CFile(filename);
|
|
|
+
|
|
|
+ if (rfn.isLocal())
|
|
|
+ {
|
|
|
StringBuffer tmplocal;
|
|
|
- return new CFile(rfn.getLocalPath(tmplocal).str());
|
|
|
+ rfn.getLocalPath(tmplocal);
|
|
|
+ return new CFile(tmplocal);
|
|
|
}
|
|
|
+
|
|
|
+ /* NB: to get here, no hook has returned a result and the file is non-local and prefixed with // or \\ */
|
|
|
#ifdef _WIN32
|
|
|
+ /* NB: this windows specific code below should really be refactored into the standard
|
|
|
+ * hook mechanism. And any path translation should be left/done on the remote side
|
|
|
+ * once it gets to dafilersv.
|
|
|
+ */
|
|
|
StringBuffer tmplocal;
|
|
|
- if (linremote||(rfn.queryEndpoint().port!=0)) {
|
|
|
- ret = createIFileByHook(rfn); // use daliservix in preference
|
|
|
- if (ret)
|
|
|
- return ret;
|
|
|
- while (*filename) { // no daliservix so swap '/' for '\' and hope for best
|
|
|
+ if (linremote||(rfn.queryEndpoint().port!=0))
|
|
|
+ {
|
|
|
+ while (*filename) // no daliservix so swap '/' for '\' and hope for best
|
|
|
+ {
|
|
|
if (*filename=='/')
|
|
|
tmplocal.append('\\');
|
|
|
else
|
|
@@ -4127,21 +4143,22 @@ IFile * createIFile(const char * filename)
|
|
|
filename++;
|
|
|
}
|
|
|
filename =tmplocal.str();
|
|
|
- }
|
|
|
+ }
|
|
|
return new CWindowsRemoteFile(filename);
|
|
|
#else
|
|
|
#ifdef USE_SAMBA
|
|
|
- if(strncmp(filename, "smb://", 6) == 0)
|
|
|
- return new CSambaRemoteFile(filename);
|
|
|
- if(memcmp(filename, "//", 2) == 0) {
|
|
|
+ if (memcmp(filename, "//", 2) == 0)
|
|
|
+ {
|
|
|
StringBuffer smbfile("smb:");
|
|
|
smbfile.append(filename);
|
|
|
return new CSambaRemoteFile(smbfile.str());
|
|
|
}
|
|
|
- if(memcmp(filename, "\\\\", 2) == 0) {
|
|
|
+ if (memcmp(filename, "\\\\", 2) == 0)
|
|
|
+ {
|
|
|
StringBuffer smbfile("smb:");
|
|
|
int i = 0;
|
|
|
- while(filename[i]) {
|
|
|
+ while(filename[i])
|
|
|
+ {
|
|
|
if(filename[i] == '\\')
|
|
|
smbfile.append('/');
|
|
|
else
|
|
@@ -4153,18 +4170,12 @@ IFile * createIFile(const char * filename)
|
|
|
#else
|
|
|
if (memcmp(filename,"smb://",6)==0) // don't support samba - try remote
|
|
|
return createIFile(filename+4);
|
|
|
- ret = createIFileByHook(rfn);
|
|
|
- if (!ret)
|
|
|
- throw MakeStringException(-1, "CreateIFile::cannot attach to %s. (remote.so not linked?)", filename);
|
|
|
- return ret;
|
|
|
#endif
|
|
|
- return new CFile(filename);
|
|
|
-
|
|
|
+ throw MakeStringException(-1, "createIFile: cannot attach to %s", filename);
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
IFileIOStream * createIOStream(IFileIO * file)
|
|
|
{
|
|
|
return new CFileIOStream(file);
|