diff --git a/ecllibrary/std/File.ecl b/ecllibrary/std/File.ecl index 4e0da7189ae..bb508adb422 100644 --- a/ecllibrary/std/File.ecl +++ b/ecllibrary/std/File.ecl @@ -209,9 +209,10 @@ EXPORT SetFileDescription(varstring lfn, varstring val) := * system running on the remote machine. * @param mask The filemask specifying which files to include in the result. Defaults to '*' (all files). * @param recurse Whether to include files from subdirectories under the directory. Defaults to FALSE. + * @param planeName The name of the data plane containing the file. */ -EXPORT dataset(FsFilenameRecord) RemoteDirectory(varstring machineIP, varstring dir, varstring mask='*', boolean recurse=FALSE) := - lib_fileservices.FileServices.RemoteDirectory(machineIP, dir, mask, recurse); +EXPORT dataset(FsFilenameRecord) RemoteDirectory(varstring machineIP, varstring dir, varstring mask='*', boolean recurse=FALSE, varstring planeName='') := + lib_fileservices.FileServices.RemoteDirectory(machineIP, dir, mask, recurse, planeName); /** * Returns a dataset of information about the logical files known to the system. diff --git a/plugins/fileservices/fileservices.cpp b/plugins/fileservices/fileservices.cpp index 0ad6b7e52af..c2fe3f389f8 100644 --- a/plugins/fileservices/fileservices.cpp +++ b/plugins/fileservices/fileservices.cpp @@ -2092,18 +2092,9 @@ FILESERVICES_API char * FILESERVICES_CALL fsGetFileDescription(ICodeContext *ct return CTXSTRDUP(parentCtx, ""); } -FILESERVICES_API void FILESERVICES_CALL fsRemoteDirectory(size32_t & __lenResult,void * & __result, const char *machine, const char *dir, const char *mask, bool sub) +static void listRemoteDirectoryFiles(RemoteFilename &rfn, const char *mask, bool sub, size32_t &__lenResult, void *&__result) { MemoryBuffer mb; - RemoteFilename rfn; - SocketEndpoint ep(machine); - if (ep.isNull()){ - if (machine) - throw MakeStringException(-1, "RemoteDirectory: Could not resolve host '%s'", machine); - ep.setLocalHost(0); - } - - rfn.setPath(ep,dir); Owned f = createIFile(rfn); if (f) { StringBuffer s; @@ -2887,6 +2878,27 @@ FILESERVICES_API void FILESERVICES_CALL fsCreateExternalDirectory_v2(ICodeContex implementCreateExternalDirectory(ctx,location,path,planename); } +static void implementListPlaneDirectory(ICodeContext *ctx,const char *planename,const char *machine,const char *dir, + const char *mask,bool sub,size32_t &lenresult,void *&result) +{ + Owned plane = checkPlaneOrHost(planename,machine,dir); + RemoteFilename rfn; + checkExternalFilePath(ctx,plane,machine,dir,true,false,rfn); + listRemoteDirectoryFiles(rfn,mask,sub,lenresult,result); +} + +FILESERVICES_API void FILESERVICES_CALL fsRemoteDirectory(ICodeContext *ctx,size32_t &lenresult, + void *&result,const char *machine,const char *dir,const char *mask,bool sub) +{ + implementListPlaneDirectory(ctx,nullptr,machine,dir,mask,sub,lenresult,result); +} + +FILESERVICES_API void FILESERVICES_CALL fsRemoteDirectory_v2(ICodeContext *ctx,size32_t &lenresult, + void *&result,const char *machine,const char *dir,const char *mask,bool sub,const char *planename) +{ + implementListPlaneDirectory(ctx,planename,machine,dir,mask,sub,lenresult,result); +} + FILESERVICES_API char * FILESERVICES_CALL fsfGetLogicalFileAttribute(ICodeContext * ctx,const char *_lfn,const char *attrname) { StringBuffer lfn; diff --git a/plugins/fileservices/fileservices.hpp b/plugins/fileservices/fileservices.hpp index dfc9447d021..0bd5e5fee85 100644 --- a/plugins/fileservices/fileservices.hpp +++ b/plugins/fileservices/fileservices.hpp @@ -146,7 +146,8 @@ FILESERVICES_API char * FILESERVICES_CALL fsfMonitorLogicalFileName(ICodeContex FILESERVICES_API char * FILESERVICES_CALL fsfMonitorFile(ICodeContext *ctx, const char *eventname, const char *ip, const char *filename, bool sub, int shotcount, const char * espServerIpPort); FILESERVICES_API void FILESERVICES_CALL fsSetFileDescription(ICodeContext *ctx, const char *logicalfilename, const char *value); FILESERVICES_API char * FILESERVICES_CALL fsGetFileDescription(ICodeContext *ctx, const char *logicalfilename); -FILESERVICES_API void FILESERVICES_CALL fsRemoteDirectory(size32_t & __lenResult,void * & __result, const char *machineip, const char *dir, const char *mask, bool sub); +FILESERVICES_API void FILESERVICES_CALL fsRemoteDirectory(ICodeContext *ctx, size32_t & __lenResult,void * & __result, const char *machineip, const char *dir, const char *mask, bool sub); +FILESERVICES_API void FILESERVICES_CALL fsRemoteDirectory_v2(ICodeContext *ctx, size32_t & __lenResult,void * & __result, const char *machineip, const char *dir, const char *mask, bool sub, const char *planename); FILESERVICES_API void FILESERVICES_CALL fsLogicalFileList(ICodeContext *ctx,size32_t & __lenResult,void * & __result, const char *mask, bool includenormal, bool includesuper, bool unknownszero,const char *foreigndali); FILESERVICES_API void FILESERVICES_CALL fsSuperFileContents(ICodeContext *ctx,size32_t & __lenResult,void * & __result, const char *lsuperlfn, bool recurse); FILESERVICES_API void FILESERVICES_CALL fsLogicalFileSuperOwners(ICodeContext *ctx,size32_t & __lenResult,void * & __result, const char *lfn); diff --git a/plugins/proxies/lib_fileservices.ecllib b/plugins/proxies/lib_fileservices.ecllib index 9dea5cf0421..fc8db8d65c8 100644 --- a/plugins/proxies/lib_fileservices.ecllib +++ b/plugins/proxies/lib_fileservices.ecllib @@ -77,7 +77,7 @@ export FileServices := SERVICE : plugin('fileservices'), time varstring fReplicate(const varstring logicalName, integer4 timeOut=-1, const varstring espServerIpPort=GETENV('ws_fs_server')) : c,action,context,entrypoint='fsfReplicate'; varstring GetFileDescription(const varstring lfn) : c,context,entrypoint='fsGetFileDescription'; SetFileDescription(const varstring lfn,const varstring val) : c,action,context,entrypoint='fsSetFileDescription'; - dataset(FsFilenameRecord) RemoteDirectory(const varstring machineIP,const varstring dir,const varstring mask='*',boolean sub=false) : c,entrypoint='fsRemoteDirectory'; + dataset(FsFilenameRecord) RemoteDirectory(const varstring machineIP,const varstring dir,const varstring mask='*',boolean sub=false,const varstring planeName='') : c,context,entrypoint='fsRemoteDirectory_v2'; dataset(FsLogicalFileInfoRecord) LogicalFileList(const varstring namepattern='*',boolean includenormal=true,boolean includesuper=false,boolean unknownszero=false,const varstring foreigndali='') : c,context,entrypoint='fsLogicalFileList'; dataset(FsLogicalFileNameRecord) SuperFileContents(const varstring lsuperfn,boolean recurse=false) : c,context,entrypoint='fsSuperFileContents'; dataset(FsLogicalFileNameRecord) LogicalFileSuperOwners(const varstring lfn) : c,context,entrypoint='fsLogicalFileSuperOwners';