Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31212 Add plane name to RemoteDirectory #18292

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ecllibrary/std/File.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 22 additions & 10 deletions plugins/fileservices/fileservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IFile> f = createIFile(rfn);
if (f) {
StringBuffer s;
Expand Down Expand Up @@ -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<IPropertyTree> 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;
Expand Down
3 changes: 2 additions & 1 deletion plugins/fileservices/fileservices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/proxies/lib_fileservices.ecllib
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading