File.ecl 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. /*##############################################################################
  2. ## HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. All rights reserved.
  3. ############################################################################## */
  4. EXPORT File := MODULE
  5. IMPORT lib_fileservices;
  6. /*------------------------------------- Various types and constants -----------------------------------------------*/
  7. /**
  8. * A record containing information about filename. Includes name, size and when last modified.
  9. * export FsFilenameRecord := RECORD
  10. * string name;
  11. * integer8 size;
  12. * string19 modified;
  13. * END;
  14. */
  15. EXPORT FsFilenameRecord := lib_fileservices.FsFilenameRecord;
  16. /**
  17. * An alias for a logical filename that is stored in a row.
  18. */
  19. EXPORT FsLogicalFileName := lib_fileservices.FsLogicalFileName;
  20. /**
  21. * A record containing a logical filename. It contains the following fields:
  22. *
  23. * @field name The logical name of the file;
  24. */
  25. EXPORT FsLogicalFileNameRecord := lib_fileservices.FsLogicalFileNameRecord;
  26. /**
  27. * A record containing information about a logical file.
  28. *
  29. * @inherits Contains all the fields in FsLogicalFileNameRecord)
  30. * @field superfile Is this a superfile?
  31. * @field size Number of bytes in the file (before compression)
  32. * @field rowcount Number of rows in the file.
  33. * @modified Timestamp when the file was last modified;
  34. * @owner The username of the owner who ran the job to create this file.
  35. * @cluster The cluster that this file was created on.
  36. */
  37. EXPORT FsLogicalFileInfoRecord := lib_fileservices.FsLogicalFileInfoRecord;
  38. /**
  39. * A record containing information about a superfile and its contents.
  40. *
  41. * @field supername The name of the superfile
  42. * @field subname The name of the sub-file
  43. */
  44. EXPORT FsLogicalSuperSubRecord := lib_fileservices.FsLogicalSuperSubRecord;
  45. /**
  46. * A record containing information about the relationship between two files.
  47. *
  48. * @field primaryfile The logical filename of the primary file
  49. * @field secondaryfile The logical filename of the secondary file.
  50. * @field primaryflds The name of the primary key field for the primary file. The value "__fileposition__"
  51. * indicates the secondary is an INDEX that must use FETCH to access non-keyed fields.
  52. * @field secondaryflds The name of the foreign key field relating to the primary file.
  53. * @field kind The type of relationship between the primary and secondary files.
  54. * Containing either 'link' or 'view'.
  55. * @field cardinality The cardinality of the relationship. The format is <primary>:<secondary>. Valid values are
  56. * "1" or "M".
  57. * @field payload Indicates whether the primary or secondary are payload INDEXes.
  58. * @field description The description of the relationship.
  59. */
  60. EXPORT FsFileRelationshipRecord := lib_fileservices.FsFileRelationshipRecord;
  61. /**
  62. * Constant that indicates IBM RECFM V format file. Can be passed to SprayFixed for the record size.
  63. */
  64. EXPORT RECFMV_RECSIZE := lib_fileservices.RECFMV_RECSIZE;
  65. /**
  66. * Constant that indicates IBM RECFM VB format file. Can be passed to SprayFixed for the record size.
  67. */
  68. EXPORT RECFMVB_RECSIZE := lib_fileservices.RECFMVB_RECSIZE;
  69. /**
  70. * Constant that indicates a variable little endian 4 byte length prefixed file. Can be passed to SprayFixed for the record size.
  71. */
  72. EXPORT INTEGER4 PREFIX_VARIABLE_RECSIZE := lib_fileservices.PREFIX_VARIABLE_RECSIZE;
  73. /**
  74. * Constant that indicates a variable big endian 4 byte length prefixed file. Can be passed to SprayFixed for the record size.
  75. */
  76. EXPORT INTEGER4 PREFIX_VARIABLE_BIGENDIAN_RECSIZE := lib_fileservices.PREFIX_VARIABLE_BIGENDIAN_RECSIZE;
  77. EXPORT FsDropZone := lib_fileservices.FsDropZone;
  78. EXPORT FsDropZoneRecord := lib_fileservices.FsDropZoneRecord;
  79. /*------------------------------------- Spray functions -----------------------------------------------------------*/
  80. /**
  81. * Returns whether the file exists.
  82. *
  83. * @param lfn The logical name of the file.
  84. * @param physical Whether to also check for the physical existence on disk. Defaults to FALSE.
  85. * @return Whether the file exists.
  86. */
  87. EXPORT boolean FileExists(varstring lfn, boolean physical=FALSE) :=
  88. lib_fileservices.FileServices.FileExists(lfn, physical);
  89. /**
  90. * Removes the logical file from the system, and deletes from the disk.
  91. *
  92. * @param lfn The logical name of the file.
  93. * @param allowMissing Whether to suppress an error if the filename does not exist. Defaults to FALSE.
  94. */
  95. EXPORT DeleteLogicalFile(varstring lfn, boolean allowMissing=FALSE) :=
  96. lib_fileservices.FileServices.DeleteLogicalFile(lfn, allowMissing);
  97. /**
  98. * Changes whether access to a file is read only or not.
  99. *
  100. * @param lfn The logical name of the file.
  101. * @param ro Whether updates to the file are disallowed. Defaults to TRUE.
  102. */
  103. EXPORT SetReadOnly(varstring lfn, boolean ro=TRUE) :=
  104. lib_fileservices.FileServices.SetReadOnly(lfn, ro);
  105. /**
  106. * Changes the name of a logical file.
  107. *
  108. * @param oldname The current name of the file to be renamed.
  109. * @param newname The new logical name of the file.
  110. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  111. */
  112. EXPORT RenameLogicalFile(varstring oldname, varstring newname, boolean allowOverwrite=FALSE) :=
  113. lib_fileservices.FileServices.RenameLogicalFile(oldname, newname, allowOverwrite);
  114. /**
  115. * Returns a logical filename that can be used to refer to a logical file in a local or remote dali.
  116. *
  117. * @param name The logical name of the file.
  118. * @param foreigndali The IP address of the foreign dali used to resolve the file. If blank then the file is resolved
  119. * locally. Defaults to blank.
  120. * @param abspath Should a tilde (~) be prepended to the resulting logical file name. Defaults to FALSE.
  121. */
  122. EXPORT varstring ForeignLogicalFileName(varstring name, varstring foreigndali='', boolean abspath=FALSE, boolean omitClusterPrefix=FALSE) :=
  123. lib_fileservices.FileServices.ForeignLogicalFileName(name, foreigndali, abspath, omitClusterPrefix);
  124. /**
  125. * Returns an encoded logical filename that can be used to refer to a external file. Examples include directly
  126. * reading from a landing zone. Upper case characters and other details are escaped.
  127. *
  128. * @param location The IP address of the remote machine. '.' can be used for the local machine.
  129. * @param path The path/name of the file on the remote machine.
  130. * @param abspath Should a tilde (~) be prepended to the resulting logical file name. Defaults to TRUE.
  131. * @return The encoded logical filename.
  132. */
  133. EXPORT varstring ExternalLogicalFileName(varstring location, varstring path, boolean abspath=TRUE) :=
  134. lib_fileservices.FileServices.ExternalLogicalFileName(location, path, abspath);
  135. /**
  136. * Returns a string containing the description information associated with the specified filename. This description
  137. * is set either through ECL watch or by using the FileServices.SetFileDescription function.
  138. *
  139. * @param lfn The logical name of the file.
  140. */
  141. EXPORT varstring GetFileDescription(varstring lfn) :=
  142. lib_fileservices.FileServices.GetFileDescription(lfn);
  143. /**
  144. * Sets the description associated with the specified filename.
  145. *
  146. * @param lfn The logical name of the file.
  147. * @param val The description to be associated with the file.
  148. */
  149. EXPORT SetFileDescription(varstring lfn, varstring val) :=
  150. lib_fileservices.FileServices.SetFileDescription(lfn, val);
  151. /**
  152. * Returns a dataset containing a list of files from the specified machineIP and directory.
  153. *
  154. * @param machineIP The IP address of the remote machine.
  155. * @param directory The path to the directory to read. This must be in the appropriate format for the operating
  156. * system running on the remote machine.
  157. * @param mask The filemask specifying which files to include in the result. Defaults to '*' (all files).
  158. * @param recurse Whether to include files from subdirectories under the directory. Defaults to FALSE.
  159. */
  160. EXPORT dataset(FsFilenameRecord) RemoteDirectory(varstring machineIP, varstring dir, varstring mask='*', boolean recurse=FALSE) :=
  161. lib_fileservices.FileServices.RemoteDirectory(machineIP, dir, mask, recurse);
  162. /**
  163. * Returns a dataset of information about the logical files known to the system.
  164. *
  165. * @param namepattern The mask of the files to list. Defaults to '*' (all files).
  166. * @param includenormal Whether to include 'normal' files. Defaults to TRUE.
  167. * @param includesuper Whether to include SuperFiles. Defaults to FALSE.
  168. * @param unknownszero Whether to set file sizes that are unknown to zero(0) instead of minus-one (-1). Defaults to FALSE.
  169. * @param foreigndali The IP address of the foreign dali used to resolve the file. If blank then the file is resolved
  170. * locally. Defaults to blank.
  171. */
  172. EXPORT dataset(FsLogicalFileInfoRecord) LogicalFileList(varstring namepattern='*', boolean includenormal=TRUE, boolean includesuper=FALSE, boolean unknownszero=FALSE, varstring foreigndali='') :=
  173. lib_fileservices.FileServices.LogicalFileList(namepattern, includenormal, includesuper, unknownszero, foreigndali);
  174. /**
  175. * Compares two files, and returns a result indicating how well they match.
  176. *
  177. * @param file1 The logical name of the first file.
  178. * @param file2 The logical name of the second file.
  179. * @param logical_only Whether to only compare logical information in the system datastore (Dali), and ignore physical
  180. information on disk. [Default TRUE]
  181. * @param use_crcs Whether to compare physical CRCs of all the parts on disk. This may be slow on large files.
  182. Defaults to FALSE.
  183. * @return 0 if file1 and file2 match exactly
  184. * 1 if file1 and file2 contents match, but file1 is newer than file2
  185. * -1 if file1 and file2 contents match, but file2 is newer than file1
  186. * 2 if file1 and file2 contents do not match and file1 is newer than file2
  187. * -2 if file1 and file2 contents do not match and file2 is newer than file1
  188. */
  189. EXPORT INTEGER4 CompareFiles(varstring lfn1, varstring lfn2, boolean logical_only=TRUE, boolean use_crcs=FALSE) :=
  190. lib_fileservices.FileServices.CompareFiles(lfn1, lfn2, logical_only, use_crcs);
  191. /**
  192. * Checks the system datastore (Dali) information for the file against the physical parts on disk.
  193. *
  194. * @param lfn The name of the file to check.
  195. * @param use_crcs Whether to compare physical CRCs of all the parts on disk. This may be slow on large files.
  196. * @return 'OK' - The file parts match the datastore information
  197. * 'Could not find file: <filename>' - The logical filename was not found
  198. * 'Could not find part file: <partname>' - The partname was not found
  199. * 'Modified time differs for: <partname>' - The partname has a different timestamp
  200. * 'File size differs for: <partname>' - The partname has a file size
  201. * 'File CRC differs for: <partname>' - The partname has a different CRC
  202. */
  203. EXPORT varstring VerifyFile(varstring lfn, boolean usecrcs) :=
  204. lib_fileservices.FileServices.VerifyFile(lfn, usecrcs);
  205. /**
  206. * Defines the relationship between two files. These may be DATASETs or INDEXes. Each record in the primary file
  207. * should be uniquely defined by the primaryfields (ideally), preferably efficiently. This information is used
  208. * by the roxie browser to link files together.
  209. *
  210. * @param primary The logical filename of the primary file.
  211. * @param secondary The logical filename of the secondary file.
  212. * @param primaryfields The name of the primary key field for the primary file. The value "__fileposition__"
  213. * indicates the secondary is an INDEX that must use FETCH to access non-keyed fields.
  214. * @param secondaryfields The name of the foreign key field relating to the primary file.
  215. * @param relationship The type of relationship between the primary and secondary files.
  216. * Containing either 'link' or 'view'. Default is "link".
  217. * @param cardinality The cardinality of the relationship. The format is <primary>:<secondary>. Valid values are
  218. * "1" or "M".
  219. * @param payload Indicates whether the primary or secondary are payload INDEXes.
  220. * @param description The description of the relationship.
  221. */
  222. EXPORT AddFileRelationship(varstring primary, varstring secondary, varstring primaryflds, varstring secondaryflds, varstring kind='link', varstring cardinality, boolean payload, varstring description='') :=
  223. lib_fileservices.FileServices.AddFileRelationship(primary, secondary, primaryflds, secondaryflds, kind, cardinality, payload, description);
  224. /**
  225. * Returns a dataset of relationships. The return records are structured in the FsFileRelationshipRecord format.
  226. *
  227. * @param primary The logical filename of the primary file.
  228. * @param secondary The logical filename of the secondary file.</para>
  229. * @param primaryfields The name of the primary key field for the primary file.
  230. * @param secondaryfields The name of the foreign key field relating to the primary file.
  231. * @param relationship The type of relationship between the primary and secondary files.
  232. * Containing either 'link' or 'view'. Default is "link".
  233. */
  234. EXPORT dataset(FsFileRelationshipRecord) FileRelationshipList(varstring primary, varstring secondary, varstring primflds='', varstring secondaryflds='', varstring kind='link') :=
  235. lib_fileservices.FileServices.FileRelationshipList(primary, secondary, primflds, secondaryflds, kind);
  236. /**
  237. * Removes a relationship between two files.
  238. *
  239. * @param primary The logical filename of the primary file.
  240. * @param secondary The logical filename of the secondary file.
  241. * @param primaryfields The name of the primary key field for the primary file.
  242. * @param secondaryfields The name of the foreign key field relating to the primary file.
  243. * @param relationship The type of relationship between the primary and secondary files.
  244. * Containing either 'link' or 'view'. Default is "link".
  245. */
  246. EXPORT RemoveFileRelationship(varstring primary, varstring secondary, varstring primaryflds='', varstring secondaryflds='', varstring kind='link') :=
  247. lib_fileservices.FileServices.RemoveFileRelationship(primary, secondary, primaryflds, secondaryflds, kind);
  248. /**
  249. * Returns the field mappings for the file, in the same format specified for the SetColumnMapping function.
  250. *
  251. * @param lfn The logical filename of the primary file.
  252. */
  253. EXPORT varstring GetColumnMapping(varstring lfn) :=
  254. lib_fileservices.FileServices.GetColumnMapping(lfn);
  255. /**
  256. * Defines how the data in the fields of the file mist be transformed between the actual data storage format and the
  257. * input format used to query that data. This is used by the user interface of the roxie browser.
  258. *
  259. * @param lfn The logical filename of the primary file.
  260. * @param mapping A string containing a comma separated list of field mappings.
  261. */
  262. EXPORT SetColumnMapping(varstring lfn, varstring mapping) :=
  263. lib_fileservices.FileServices.SetColumnMapping(lfn, mapping);
  264. /**
  265. * Returns a string that can be used in a DATASET declaration to read data from an RFS (Remote File Server) instance
  266. * (e.g. rfsmysql) on another node.
  267. *
  268. * @param server A string containing the ip:port address for the remote file server.
  269. * @param query The text of the query to send to the server
  270. */
  271. EXPORT varstring EncodeRfsQuery(varstring server, varstring query) :=
  272. lib_fileservices.FileServices.RfsQuery(server, query);
  273. /**
  274. * Sends the query to the rfs server.
  275. *
  276. * @param server A string containing the ip:port address for the remote file server.
  277. * @param query The text of the query to send to the server
  278. */
  279. EXPORT RfsAction(varstring server, varstring query) :=
  280. lib_fileservices.FileServices.RfsAction(server, query);
  281. /**
  282. * Moves the single physical file between two locations on the same remote machine. The
  283. * dafileserv utility program must be running on the location machine.
  284. *
  285. * @param location The IP address of the remote machine.
  286. * @param frompath The path/name of the file to move.
  287. * @param topath The path/name of the target file.
  288. */
  289. EXPORT MoveExternalFile(varstring location, varstring frompath, varstring topath) :=
  290. lib_fileservices.FileServices.MoveExternalFile(location, frompath, topath);
  291. /**
  292. * Removes a single physical file from a remote machine. The
  293. * dafileserv utility program must be running on the location machine.
  294. *
  295. * @param location The IP address of the remote machine.
  296. * @param path The path/name of the file to remove.
  297. */
  298. EXPORT DeleteExternalFile(varstring location, varstring path) :=
  299. lib_fileservices.FileServices.DeleteExternalFile(location, path);
  300. /**
  301. * Creates the path on the location (if it does not already exist). The
  302. * dafileserv utility program must be running on the location machine.
  303. *
  304. * @param location The IP address of the remote machine.
  305. * @param path The path/name of the file to remove.
  306. */
  307. EXPORT CreateExternalDirectory(varstring location, varstring path) :=
  308. lib_fileservices.FileServices.CreateExternalDirectory(location, path);
  309. /**
  310. * Returns the value of the given attribute for the specified logicalfilename.
  311. *
  312. * @param lfn The name of the logical file.
  313. * @param attrname The name of the file attribute to return.
  314. */
  315. EXPORT varstring GetLogicalFileAttribute(varstring lfn, varstring attrname) :=
  316. lib_fileservices.FileServices.GetLogicalFileAttribute(lfn, attrname);
  317. /**
  318. * Toggles protection on and off for the specified logicalfilename.
  319. *
  320. * @param lfn The name of the logical file.
  321. * @param value TRUE to enable protection, FALSE to disable.
  322. */
  323. EXPORT ProtectLogicalFile(varstring lfn, boolean value=TRUE) :=
  324. lib_fileservices.FileServices.ProtectLogicalFile(lfn, value);
  325. /**
  326. * The DfuPlusExec action executes the specified command line just as the DfuPLus.exe program would do. This
  327. * allows you to have all the functionality of the DfuPLus.exe program available within your ECL code.
  328. *
  329. * param cmdline The DFUPlus.exe command line to execute. The valid arguments are documented in the Client
  330. * Tools manual, in the section describing the DfuPlus.exe program.
  331. */
  332. EXPORT DfuPlusExec(varstring cmdline) :=
  333. lib_fileservices.FileServices.DfuPlusExec(cmdline);
  334. /*------------------------------------- Spray functions -----------------------------------------------------------*/
  335. /**
  336. * Sprays a file of fixed length records from a single machine and distributes it across the nodes of the
  337. * destination group.
  338. *
  339. * @param sourceIP The IP address of the file.
  340. * @param sourcePath The path and name of the file.
  341. * @param recordsize The size (in bytes) of the records in the file.
  342. * @param destinationGroup The name of the group to distribute the file across.
  343. * @param destinationLogicalName The logical name of the file to create.
  344. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  345. * Defaults to no timeout (-1).
  346. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  347. * @param maxConnections The maximum number of target nodes to write to concurrently. Defaults to 1.
  348. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  349. * @param replicate Whether to replicate the new file. Defaults to FALSE.
  350. * @param compress Whether to compress the new file. Defaults to FALSE.
  351. * @param failIfNoSourceFile If TRUE it causes a missing source file to trigger a failure. Defaults to FALSE.
  352. * @param expireDays Number of days to auto-remove file. Default is -1, not expire.
  353. * @param dfuServerQueue Name of target DFU Server queue. Default is '' (empty) for the first DFU queue in the environment.
  354. * @param noSplit Don't split a file part to multiple target parts. Default is FALSE.
  355. * @return The DFU workunit id for the job.
  356. */
  357. EXPORT varstring fSprayFixed(varstring sourceIP, varstring sourcePath, integer4 recordSize, varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, boolean failIfNoSourceFile=FALSE, integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  358. lib_fileservices.FileServices.fSprayFixed(sourceIP, sourcePath, recordSize, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, failIfNoSourceFile, expireDays, dfuServerQueue, noSplit);
  359. /**
  360. * Same as fSprayFixed, but does not return the DFU Workunit ID.
  361. *
  362. * @see fSprayFixed
  363. */
  364. EXPORT SprayFixed(varstring sourceIP, varstring sourcePath, integer4 recordSize, varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, boolean failIfNoSourceFile=FALSE, integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  365. lib_fileservices.FileServices.SprayFixed(sourceIP, sourcePath, recordSize, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, failIfNoSourceFile, expireDays, dfuServerQueue, noSplit);
  366. // fSprayVariable is now called fSprayDelimited (but the old name is available for backward compatibility)
  367. EXPORT varstring fSprayVariable(varstring sourceIP, varstring sourcePath, integer4 sourceMaxRecordSize=8192, varstring sourceCsvSeparate='\\,', varstring sourceCsvTerminate='\\n,\\r\\n', varstring sourceCsvQuote='\"', varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, varstring sourceCsvEscape='', boolean failIfNoSourceFile=FALSE, boolean recordStructurePresent=FALSE, boolean quotedTerminator=TRUE, varstring encoding='ascii', integer4 expireDays=-1, varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  368. lib_fileservices.FileServices.fSprayVariable(sourceIP, sourcePath, sourceMaxRecordSize, sourceCsvSeparate, sourceCsvTerminate, sourceCsvQuote, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, sourceCsvEscape, failIfNoSourceFile, recordStructurePresent, quotedTerminator, encoding, expireDays, dfuServerQueue, noSplit);
  369. // SprayVariable is now called SprayDelimited (but the old name is available for backward compatibility)
  370. EXPORT SprayVariable(varstring sourceIP, varstring sourcePath, integer4 sourceMaxRecordSize=8192, varstring sourceCsvSeparate='\\,', varstring sourceCsvTerminate='\\n,\\r\\n', varstring sourceCsvQuote='\"', varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, varstring sourceCsvEscape='', boolean failIfNoSourceFile=FALSE, boolean recordStructurePresent=FALSE, boolean quotedTerminator=TRUE, varstring encoding='ascii', integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  371. lib_fileservices.FileServices.SprayVariable(sourceIP, sourcePath, sourceMaxRecordSize, sourceCsvSeparate, sourceCsvTerminate, sourceCsvQuote, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, sourceCsvEscape, failIfNoSourceFile, recordStructurePresent, quotedTerminator, encoding, expireDays, dfuServerQueue, noSplit);
  372. /**
  373. * Sprays a file of fixed delimited records from a single machine and distributes it across the nodes of the
  374. * destination group.
  375. *
  376. * @param sourceIP The IP address of the file.
  377. * @param sourcePath The path and name of the file.
  378. * @param sourceCsvSeparate The character sequence which separates fields in the file.
  379. * @param sourceCsvTerminate The character sequence which separates records in the file.
  380. * @param sourceCsvQuote A string which can be used to delimit fields in the file.
  381. * @param sourceMaxRecordSize The maximum size (in bytes) of the records in the file.
  382. * @param destinationGroup The name of the group to distribute the file across.
  383. * @param destinationLogicalName The logical name of the file to create.
  384. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  385. * Defaults to no timeout (-1).
  386. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  387. * @param maxConnections The maximum number of target nodes to write to concurrently. Defaults to 1.
  388. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  389. * @param replicate Whether to replicate the new file. Defaults to FALSE.
  390. * @param compress Whether to compress the new file. Defaults to FALSE.
  391. * @param sourceCsvEscape A character that is used to escape quote characters. Defaults to none.
  392. * @param failIfNoSourceFile If TRUE it causes a missing source file to trigger a failure. Defaults to FALSE.
  393. * @param recordStructurePresent If TRUE derives the record structure from the header of the file.
  394. * @param quotedTerminator Can the terminator character be included in a quoted field. Defaults to TRUE.
  395. * If FALSE it allows quicker partitioning of the file (avoiding a complete file scan).
  396. * @param encoding A null-terminated string containing the encoding.
  397. * Can be set to one of the following:
  398. * ascii, utf8, utf8n, utf16, utf16le, utf16be, utf32, utf32le,utf32be. If omitted, the default is ascii.
  399. * @param expireDays Number of days to auto-remove file. Default is -1, not expire.
  400. * @param dfuServerQueue Name of target DFU Server queue. Default is '' (empty) for the first DFU queue in the environment.
  401. * @param noSplit Don't split a file part to multiple target parts. Default is FALSE.
  402. * @return The DFU workunit id for the job.
  403. */
  404. EXPORT varstring fSprayDelimited(varstring sourceIP, varstring sourcePath, integer4 sourceMaxRecordSize=8192, varstring sourceCsvSeparate='\\,', varstring sourceCsvTerminate='\\n,\\r\\n', varstring sourceCsvQuote='\"', varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, varstring sourceCsvEscape='', boolean failIfNoSourceFile=FALSE, boolean recordStructurePresent=FALSE, boolean quotedTerminator=TRUE, varstring encoding='ascii', integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  405. lib_fileservices.FileServices.fSprayVariable(sourceIP, sourcePath, sourceMaxRecordSize, sourceCsvSeparate, sourceCsvTerminate, sourceCsvQuote, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, sourceCsvEscape, failIfNoSourceFile, recordStructurePresent, quotedTerminator, encoding, expireDays, dfuServerQueue, noSplit);
  406. /**
  407. * Same as fSprayDelimited, but does not return the DFU Workunit ID.
  408. *
  409. * @see fSprayDelimited
  410. */
  411. EXPORT SprayDelimited(varstring sourceIP, varstring sourcePath, integer4 sourceMaxRecordSize=8192, varstring sourceCsvSeparate='\\,', varstring sourceCsvTerminate='\\n,\\r\\n', varstring sourceCsvQuote='\"', varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, varstring sourceCsvEscape='', boolean failIfNoSourceFile=FALSE, boolean recordStructurePresent=FALSE, boolean quotedTerminator=TRUE, const varstring encoding='ascii', integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  412. lib_fileservices.FileServices.SprayVariable(sourceIP, sourcePath, sourceMaxRecordSize, sourceCsvSeparate, sourceCsvTerminate, sourceCsvQuote, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, sourceCsvEscape, failIfNoSourceFile, recordStructurePresent, quotedTerminator, encoding, expireDays, dfuServerQueue, noSplit);
  413. /**
  414. * Sprays an xml file from a single machine and distributes it across the nodes of the destination group.
  415. *
  416. * @param sourceIP The IP address of the file.
  417. * @param sourcePath The path and name of the file.
  418. * @param sourceMaxRecordSize The maximum size (in bytes) of the records in the file.
  419. * @param sourceRowTag The xml tag that is used to delimit records in the source file. (This tag cannot recursivly nest.)
  420. * @param sourceEncoding The unicode encoding of the file. (utf8,utf8n,utf16be,utf16le,utf32be,utf32le)
  421. * @param destinationGroup The name of the group to distribute the file across.
  422. * @param destinationLogicalName The logical name of the file to create.
  423. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  424. * Defaults to no timeout (-1).
  425. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  426. * @param maxConnections The maximum number of target nodes to write to concurrently. Defaults to 1.
  427. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  428. * @param replicate Whether to replicate the new file. Defaults to FALSE.
  429. * @param compress Whether to compress the new file. Defaults to FALSE.
  430. * @param failIfNoSourceFile If TRUE it causes a missing source file to trigger a failure. Defaults to FALSE.
  431. * @param expireDays Number of days to auto-remove file. Default is -1, not expire.
  432. * @param dfuServerQueue Name of target DFU Server queue. Default is '' (empty) for the first DFU queue in the environment.
  433. * @param noSplit Don't split a file part to multiple target parts. Default is FALSE.
  434. * @return The DFU workunit id for the job.
  435. */
  436. EXPORT varstring fSprayXml(varstring sourceIP, varstring sourcePath, integer4 sourceMaxRecordSize=8192, varstring sourceRowTag, varstring sourceEncoding='utf8', varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, boolean failIfNoSourceFile=FALSE, integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  437. lib_fileservices.FileServices.fSprayXml(sourceIP, sourcePath, sourceMaxRecordSize, sourceRowTag, sourceEncoding, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, failIfNoSourceFile, expireDays, dfuServerQueue, noSplit);
  438. /**
  439. * Same as fSprayXml, but does not return the DFU Workunit ID.
  440. *
  441. * @see fSprayXml
  442. */
  443. EXPORT SprayXml(varstring sourceIP, varstring sourcePath, integer4 sourceMaxRecordSize=8192, varstring sourceRowTag, varstring sourceEncoding='utf8', varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean compress=FALSE, boolean failIfNoSourceFile=FALSE, integer4 expireDays=-1, const varstring dfuServerQueue='', boolean noSplit=FALSE) :=
  444. lib_fileservices.FileServices.SprayXml(sourceIP, sourcePath, sourceMaxRecordSize, sourceRowTag, sourceEncoding, destinationGroup, destinationLogicalName, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, compress, failIfNoSourceFile, expireDays, dfuServerQueue, noSplit);
  445. /**
  446. * Copies a distributed file from multiple machines, and desprays it to a single file on a single machine.
  447. *
  448. * @param logicalName The name of the file to despray.
  449. * @param destinationIP The IP of the target machine.
  450. * @param destinationPath The path of the file to create on the destination machine.
  451. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  452. * Defaults to no timeout (-1).
  453. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  454. * @param maxConnections The maximum number of target nodes to write to concurrently. Defaults to 1.
  455. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  456. * @return The DFU workunit id for the job.
  457. */
  458. EXPORT varstring fDespray(varstring logicalName, varstring destinationIP, varstring destinationPath, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE) :=
  459. lib_fileservices.FileServices.fDespray(logicalName, destinationIP, destinationPath, timeOut, espServerIpPort, maxConnections, allowOverwrite);
  460. /**
  461. * Same as fDespray, but does not return the DFU Workunit ID.
  462. *
  463. * @see fDespray
  464. */
  465. EXPORT Despray(varstring logicalName, varstring destinationIP, varstring destinationPath, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE) :=
  466. lib_fileservices.FileServices.Despray(logicalName, destinationIP, destinationPath, timeOut, espServerIpPort, maxConnections, allowOverwrite);
  467. /**
  468. * Copies a distributed file to another distributed file.
  469. *
  470. * @param sourceLogicalName The name of the file to despray.
  471. * @param destinationGroup The name of the group to distribute the file across.
  472. * @param destinationLogicalName The logical name of the file to create.
  473. * @param sourceDali The dali that contains the source file (blank implies same dali). Defaults to same dali.
  474. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  475. * Defaults to no timeout (-1).
  476. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  477. * @param maxConnections The maximum number of target nodes to write to concurrently. Defaults to 1.
  478. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  479. * @param replicate Should the copied file also be replicated on the destination? Defaults to FALSE
  480. * @param asSuperfile Should the file be copied as a superfile? If TRUE and source is a superfile, then the
  481. * operation creates a superfile on the target, creating sub-files as needed and only overwriting
  482. * existing sub-files whose content has changed. If FALSE, a single file is created. Defaults to FALSE.
  483. * @param compress Whether to compress the new file. Defaults to FALSE.
  484. * @param forcePush Should the copy process be executed on the source nodes (push) or on the destination nodes (pull)?
  485. * Default is to pull.
  486. * @param transferBufferSize Overrides the size (in bytes) of the internal buffer used to copy the file. Default is 64k.
  487. * @param noSplit Don't split a file part to multiple target parts. Default is FALSE.
  488. * @param expireDays Number of days to auto-remove file. Default is -1, not expire.
  489. * @return The DFU workunit id for the job.
  490. */
  491. EXPORT varstring fCopy(varstring sourceLogicalName, varstring destinationGroup, varstring destinationLogicalName, varstring sourceDali='', integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean asSuperfile=FALSE, boolean compress=FALSE, boolean forcePush=FALSE, integer4 transferBufferSize=0, boolean preserveCompression=TRUE, boolean noSplit=FALSE, integer4 expireDays=-1) :=
  492. lib_fileservices.FileServices.fCopy(sourceLogicalName, destinationGroup, destinationLogicalName, sourceDali, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, asSuperfile, compress, forcePush, transferBufferSize, preserveCompression, noSplit, expireDays);
  493. /**
  494. * Same as fCopy, but does not return the DFU Workunit ID.
  495. *
  496. * @see fCopy
  497. */
  498. EXPORT Copy(varstring sourceLogicalName, varstring destinationGroup, varstring destinationLogicalName, varstring sourceDali='', integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server'), integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean asSuperfile=FALSE, boolean compress=FALSE, boolean forcePush=FALSE, integer4 transferBufferSize=0, boolean preserveCompression=TRUE, boolean noSplit=FALSE, integer4 expireDays=-1) :=
  499. lib_fileservices.FileServices.Copy(sourceLogicalName, destinationGroup, destinationLogicalName, sourceDali, timeOut, espServerIpPort, maxConnections, allowOverwrite, replicate, asSuperfile, compress, forcePush, transferBufferSize, preserveCompression, noSplit, expireDays);
  500. /**
  501. * Ensures the specified file is replicated to its mirror copies.
  502. *
  503. * @param logicalName The name of the file to replicate.
  504. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  505. * Defaults to no timeout (-1).
  506. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  507. * @return The DFU workunit id for the job.
  508. */
  509. EXPORT varstring fReplicate(varstring logicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  510. lib_fileservices.FileServices.fReplicate(logicalName, timeOut, espServerIpPort);
  511. /**
  512. * Same as fReplicated, but does not return the DFU Workunit ID.
  513. *
  514. * @see fReplicate
  515. */
  516. EXPORT Replicate(varstring logicalName, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  517. lib_fileservices.FileServices.Replicate(logicalName, timeOut, espServerIpPort);
  518. /**
  519. * Copies a distributed file to a distributed file on remote system. Similar to fCopy, except the copy executes
  520. * remotely. Since the DFU workunit executes on the remote DFU server, the user name authentication must be the same
  521. * on both systems, and the user must have rights to copy files on both systems.
  522. *
  523. * @param remoteEspFsURL The url of the remote ESP file copying service.
  524. * @param sourceLogicalName The name of the file to despray.
  525. * @param destinationGroup The name of the group to distribute the file across.
  526. * @param destinationLogicalName The logical name of the file to create.
  527. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  528. * Defaults to no timeout (-1).
  529. * @param maxConnections The maximum number of target nodes to write to concurrently. Defaults to 1.
  530. * @param allowOverwrite Is it valid to overwrite an existing file of the same name? Defaults to FALSE
  531. * @param replicate Should the copied file also be replicated on the destination? Defaults to FALSE
  532. * @param asSuperfile Should the file be copied as a superfile? If TRUE and source is a superfile, then the
  533. * operation creates a superfile on the target, creating sub-files as needed and only overwriting
  534. * existing sub-files whose content has changed. If FALSE a single file is created. Defaults to FALSE.
  535. * @param compress Whether to compress the new file. Defaults to FALSE.
  536. * @param forcePush Should the copy process should be executed on the source nodes (push) or on the destination nodes (pull)?
  537. * Default is to pull.
  538. * @param transferBufferSize Overrides the size (in bytes) of the internal buffer used to copy the file. Default is 64k.
  539. * @param wrap Should the fileparts be wrapped when copying to a smaller sized cluster? The default is FALSE.
  540. * @param noSplit Don't split a file part to multiple target parts. Default is FALSE.
  541. * @param expireDays Number of days to auto-remove file. Default is -1, not expire.
  542. * @return The DFU workunit id for the job.
  543. */
  544. EXPORT varstring fRemotePull(varstring remoteEspFsURL, varstring sourceLogicalName, varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean asSuperfile=FALSE, boolean forcePush=FALSE, integer4 transferBufferSize=0, boolean wrap=FALSE, boolean compress=FALSE, boolean noSplit=FALSE, integer4 expireDays=-1) :=
  545. lib_fileservices.FileServices.fRemotePull(remoteEspFsURL, sourceLogicalName, destinationGroup, destinationLogicalName, timeOut, maxConnections, allowOverwrite, replicate, asSuperfile, forcePush, transferBufferSize, wrap, compress, noSplit, expireDays);
  546. /**
  547. * Same as fRemotePull, but does not return the DFU Workunit ID.
  548. *
  549. * @see fRemotePull
  550. */
  551. EXPORT RemotePull(varstring remoteEspFsURL, varstring sourceLogicalName, varstring destinationGroup, varstring destinationLogicalName, integer4 timeOut=-1, integer4 maxConnections=-1, boolean allowOverwrite=FALSE, boolean replicate=FALSE, boolean asSuperfile=FALSE, boolean forcePush=FALSE, integer4 transferBufferSize=0, boolean wrap=FALSE, boolean compress=FALSE, boolean noSplit=FALSE, integer4 expireDays=-1) :=
  552. lib_fileservices.FileServices.RemotePull(remoteEspFsURL, sourceLogicalName, destinationGroup, destinationLogicalName, timeOut, maxConnections, allowOverwrite, replicate, asSuperfile, forcePush, transferBufferSize, wrap, compress, noSplit, expireDays);
  553. /*------------------------------------- File monitoring functions -------------------------------------------------------*/
  554. /**
  555. * Creates a file monitor job in the DFU Server. If an appropriately named file arrives in this interval it will fire
  556. * the event with the name of the triggering object as the event subtype (see the EVENT function).
  557. *
  558. * @param eventToFire The user-defined name of the event to fire when the filename appears. This value is used as
  559. * the first parameter to the EVENT function.
  560. * @param name The name of the logical file to monitor. This may contain wildcard characters ( * and ?)
  561. * @param shotCount The number of times to generate the event before the monitoring job completes. A value
  562. * of -1 indicates the monitoring job continues until manually aborted. The default is 1.
  563. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  564. * @return The DFU workunit id for the job.
  565. */
  566. EXPORT varstring fMonitorLogicalFileName(varstring eventToFire, varstring name, integer4 shotCount=1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  567. lib_fileservices.FileServices.fMonitorLogicalFileName(eventToFire, name, shotCount, espServerIpPort);
  568. /**
  569. * Same as fMonitorLogicalFileName, but does not return the DFU Workunit ID.
  570. *
  571. * @see fMonitorLogicalFileName
  572. */
  573. EXPORT MonitorLogicalFileName(varstring eventToFire, varstring name, integer4 shotCount=1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  574. lib_fileservices.FileServices.MonitorLogicalFileName(eventToFire, name, shotCount, espServerIpPort);
  575. /**
  576. * Creates a file monitor job in the DFU Server. If an appropriately named file arrives in this interval it will fire
  577. * the event with the name of the triggering object as the event subtype (see the EVENT function).
  578. *
  579. * @param eventToFire The user-defined name of the event to fire when the filename appears. This value is used as
  580. * the first parameter to the EVENT function.
  581. * @param ip The the IP address for the file to monitor. This may be omitted if the filename parameter
  582. * contains a complete URL.
  583. * @param filename The full path of the file(s) to monitor. This may contain wildcard characters ( * and ?)
  584. * @param subDirs Whether to include files in sub-directories (when the filename contains wildcards). Defaults to FALSE.
  585. * @param shotCount The number of times to generate the event before the monitoring job completes. A value
  586. * of -1 indicates the monitoring job continues until manually aborted. The default is 1.
  587. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  588. * @return The DFU workunit id for the job.
  589. */
  590. EXPORT varstring fMonitorFile(varstring eventToFire, varstring ip, varstring filename, boolean subDirs=FALSE, integer4 shotCount=1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  591. lib_fileservices.FileServices.fMonitorFile(eventToFire, ip, filename, subDirs, shotCount, espServerIpPort);
  592. /**
  593. * Same as fMonitorFile, but does not return the DFU Workunit ID.
  594. *
  595. * @see fMonitorFile
  596. */
  597. EXPORT MonitorFile(varstring eventToFire, varstring ip, varstring filename, boolean subdirs=FALSE, integer4 shotCount=1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  598. lib_fileservices.FileServices.MonitorFile(eventToFire, ip, filename, subdirs, shotCount, espServerIpPort);
  599. /**
  600. * Waits for the specified DFU workunit to finish.
  601. *
  602. * @param wuid The dfu wfid to wait for.
  603. * @param timeOut The time in ms to wait for the operation to complete. A value of 0 causes the call to return immediately.
  604. * Defaults to no timeout (-1).
  605. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  606. * @return A string containing the final status string of the DFU workunit.
  607. */
  608. EXPORT varstring WaitDfuWorkunit(varstring wuid, integer4 timeOut=-1, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  609. lib_fileservices.FileServices.WaitDfuWorkunit(wuid, timeOut, espServerIpPort);
  610. /**
  611. * Aborts the specified DFU workunit.
  612. *
  613. * @param wuid The dfu wfid to abort.
  614. * @param espServerIpPort The url of the ESP file copying service. Defaults to the value of ws_fs_server in the environment.
  615. */
  616. EXPORT AbortDfuWorkunit(varstring wuid, varstring espServerIpPort=GETENV('ws_fs_server')) :=
  617. lib_fileservices.FileServices.AbortDfuWorkunit(wuid, espServerIpPort);
  618. /*------------------------------------- Superfile functions -------------------------------------------------------*/
  619. /**
  620. * Creates an empty superfile. This function is not included in a superfile transaction.
  621. *
  622. * @param superName The logical name of the superfile.
  623. * @param sequentialParts Whether the sub-files must be sequentially ordered. Default to FALSE.
  624. * @param allowExist Indicating whether to post an error if the superfile already exists. If TRUE, no error is
  625. * posted. Defaults to FALSE.
  626. */
  627. EXPORT CreateSuperFile(varstring superName, boolean sequentialParts=FALSE, boolean allowExist=FALSE) :=
  628. lib_fileservices.FileServices.CreateSuperFile(superName, sequentialParts, allowExist);
  629. /**
  630. * Checks if the specified filename is present in the Distributed File Utility (DFU) and is a SuperFile.
  631. *
  632. * @param superName The logical name of the superfile.
  633. * @return Whether the file exists.
  634. *
  635. * @see FileExists
  636. */
  637. EXPORT boolean SuperFileExists(varstring superName) :=
  638. lib_fileservices.FileServices.SuperFileExists(superName);
  639. /**
  640. * Deletes the superfile.
  641. *
  642. * @param superName The logical name of the superfile.
  643. *
  644. * @see FileExists
  645. */
  646. EXPORT DeleteSuperFile(varstring superName, boolean deletesub=FALSE) :=
  647. lib_fileservices.FileServices.DeleteSuperFile(superName, deletesub);
  648. /**
  649. * Returns the number of sub-files contained within a superfile.
  650. *
  651. * @param superName The logical name of the superfile.
  652. * @return The number of sub-files within the superfile.
  653. */
  654. EXPORT unsigned4 GetSuperFileSubCount(varstring superName) :=
  655. lib_fileservices.FileServices.GetSuperFileSubCount(superName);
  656. /**
  657. * Returns the name of the Nth sub-file within a superfile.
  658. *
  659. * @param superName The logical name of the superfile.
  660. * @param fileNum The 1-based position of the sub-file to return the name of.
  661. * @param absPath Whether to prepend '~' to the name of the resulting logical file name.
  662. * @return The logical name of the selected sub-file.
  663. */
  664. EXPORT varstring GetSuperFileSubName(varstring superName, unsigned4 fileNum, boolean absPath=FALSE) :=
  665. lib_fileservices.FileServices.GetSuperFileSubName(superName, fileNum, absPath);
  666. /**
  667. * Returns the position of a file within a superfile.
  668. *
  669. * @param superName The logical name of the superfile.
  670. * @param subName The logical name of the sub-file.
  671. * @return The 1-based position of the sub-file within the superfile.
  672. */
  673. EXPORT unsigned4 FindSuperFileSubName(varstring superName, varstring subName) :=
  674. lib_fileservices.FileServices.FindSuperFileSubName(superName, subName);
  675. /**
  676. * Starts a superfile transaction. All superfile operations within the transaction will either be
  677. * executed atomically or rolled back when the transaction is finished.
  678. */
  679. EXPORT StartSuperFileTransaction() :=
  680. lib_fileservices.FileServices.StartSuperFileTransaction();
  681. /**
  682. * Adds a file to a superfile.
  683. *
  684. * @param superName The logical name of the superfile.
  685. * @param subName The name of the logical file to add.
  686. * @param atPos The position to add the sub-file, or 0 to append. Defaults to 0.
  687. * @param addContents Controls whether adding a superfile adds the superfile, or its contents. Defaults to FALSE (do not expand).
  688. * @param strict Check addContents only if subName is a superfile, and ensure superfiles exist.
  689. */
  690. EXPORT AddSuperFile(varstring superName, varstring subName, unsigned4 atPos=0, boolean addContents=FALSE, boolean strict=FALSE) :=
  691. lib_fileservices.FileServices.AddSuperFile(superName, subName, atPos, addContents, strict);
  692. /**
  693. * Removes a sub-file from a superfile.
  694. *
  695. * @param superName The logical name of the superfile.
  696. * @param subName The name of the sub-file to remove.
  697. * @param del Indicates whether the sub-file should also be removed from the disk. Defaults to FALSE.
  698. * @param removeContents Controls whether the contents of a sub-file which is a superfile should be recursively removed. Defaults to FALSE.
  699. */
  700. EXPORT RemoveSuperFile(varstring superName, varstring subName, boolean del=FALSE, boolean removeContents=FALSE) :=
  701. lib_fileservices.FileServices.RemoveSuperFile(superName, subName, del, removeContents);
  702. /**
  703. * Removes all sub-files from a superfile.
  704. *
  705. * @param superName The logical name of the superfile.
  706. * @param del Indicates whether the sub-files should also be removed from the disk. Defaults to FALSE.
  707. */
  708. EXPORT ClearSuperFile(varstring superName, boolean del=FALSE) :=
  709. lib_fileservices.FileServices.ClearSuperFile(superName, del);
  710. /**
  711. * Removes all soley-owned sub-files from a superfile. If a sub-file is also contained within another superfile
  712. * then it is retained.
  713. *
  714. * @param superName The logical name of the superfile.
  715. */
  716. EXPORT RemoveOwnedSubFiles(varstring superName, boolean del=FALSE) :=
  717. lib_fileservices.FileServices.RemoveOwnedSubFiles(superName, del);
  718. /**
  719. * Legacy version of RemoveOwnedSubFiles which was incorrectly named in a previous version.
  720. *
  721. * @see RemoveOwnedSubFIles
  722. */
  723. EXPORT DeleteOwnedSubFiles(varstring superName) := // Obsolete, use RemoteOwnedSubFiles
  724. lib_fileservices.FileServices.DeleteOwnedSubFiles(superName);
  725. /**
  726. * Swap the contents of two superfiles.
  727. *
  728. * @param superName1 The logical name of the first superfile.
  729. * @param superName2 The logical name of the second superfile.
  730. */
  731. EXPORT SwapSuperFile(varstring superName1, varstring superName2) :=
  732. lib_fileservices.FileServices.SwapSuperFile(superName1, superName2);
  733. /**
  734. * Removes a sub-file from a superfile and replaces it with another.
  735. *
  736. * @param superName The logical name of the superfile.
  737. * @param oldSubFile The logical name of the sub-file to remove.
  738. * @param newSubFile The logical name of the sub-file to replace within the superfile.
  739. */
  740. EXPORT ReplaceSuperFile(varstring superName, varstring oldSubFile, varstring newSubFile) :=
  741. lib_fileservices.FileServices.ReplaceSuperFile(superName, oldSubFile, newSubFile);
  742. /**
  743. * Finishes a superfile transaction. This executes all the operations since the matching StartSuperFileTransaction().
  744. * If there are any errors, then all of the operations are rolled back.
  745. */
  746. EXPORT FinishSuperFileTransaction(boolean rollback=FALSE) :=
  747. lib_fileservices.FileServices.FinishSuperFileTransaction(rollback);
  748. /**
  749. * Returns the list of sub-files contained within a superfile.
  750. *
  751. * @param superName The logical name of the superfile.
  752. * @param recurse Should the contents of child-superfiles be expanded. Default is FALSE.
  753. * @return A dataset containing the names of the sub-files.
  754. */
  755. EXPORT dataset(FsLogicalFileNameRecord) SuperFileContents(varstring superName, boolean recurse=FALSE) :=
  756. lib_fileservices.FileServices.SuperFileContents(superName, recurse);
  757. /**
  758. * Returns the list of superfiles that a logical file is contained within.
  759. *
  760. * @param name The name of the logical file.
  761. * @return A dataset containing the names of the superfiles.
  762. */
  763. EXPORT dataset(FsLogicalFileNameRecord) LogicalFileSuperOwners(varstring name) :=
  764. lib_fileservices.FileServices.LogicalFileSuperOwners(name);
  765. /**
  766. * Returns the list of all the superfiles in the system and their component sub-files.
  767. *
  768. * @return A dataset containing pairs of superName,subName for each component file.
  769. */
  770. EXPORT dataset(FsLogicalSuperSubRecord) LogicalFileSuperSubList() :=
  771. lib_fileservices.FileServices.LogicalFileSuperSubList();
  772. /**
  773. * Moves the sub-files from the first entry in the list of superfiles to the next in the list, repeating the process
  774. * through the list of superfiles.
  775. *
  776. * @param superNames A set of the names of the superfiles to act on. Any that do not exist will be created.
  777. * The contents of each superfile will be moved to the next in the list.
  778. * @param addHead A string containing a comma-delimited list of logical file names to add to the first superfile
  779. * after the promotion process is complete. Defaults to ''.
  780. * @param delTail Indicates whether to physically delete the contents moved out of the last superfile. The default is FALSE.
  781. * @param createOnlyOne Specifies whether to only create a single superfile (truncate the list at the first
  782. * non-existent superfile). The default is FALSE.
  783. * @param reverse Reverse the order of processing the superfiles list, effectively 'demoting' instead of 'promoting' the sub-files. The default is FALSE.
  784. *
  785. * @return A string containing a comma separated list of the previous sub-file contents of the emptied superfile.
  786. */
  787. EXPORT varstring fPromoteSuperFileList(set of varstring superNames, varstring addHead='', boolean delTail=FALSE, boolean createOnlyOne=FALSE, boolean reverse=FALSE) :=
  788. lib_fileservices.FileServices.fPromoteSuperFileList(superNames, addHead, delTail, createOnlyOne, reverse);
  789. /**
  790. * Same as fPromoteSuperFileList, but does not return the DFU Workunit ID.
  791. *
  792. * @see fPromoteSuperFileList
  793. */
  794. EXPORT PromoteSuperFileList(set of varstring superNames, varstring addHead='', boolean delTail=FALSE, boolean createOnlyOne=FALSE, boolean reverse=FALSE) :=
  795. lib_fileservices.FileServices.PromoteSuperFileList(superNames, addHead, delTail, createOnlyOne, reverse);
  796. /**
  797. * Returns the full URL to an ESP server process
  798. *
  799. * @param username String containing a username to use for authenticated
  800. * access to the ESP process; an empty string value
  801. * indicates that no user authentication is required;
  802. * OPTIONAL, defaults to an empty string
  803. * @param userPW String containing the password to be used with the
  804. * user cited in the username argument; if username is
  805. * empty then this will be ignored; OPTIONAL, defaults
  806. * to an empty string
  807. *
  808. * @return A string containing the full URL (including HTTP scheme
  809. * and port) to an ESP server process; if more than one
  810. * process is defined then the first found process will
  811. * be returned; will return an empty string if an ESP
  812. * server process cannot be found
  813. */
  814. EXPORT varstring GetEspURL(const varstring username = '', const varstring userPW = '') :=
  815. lib_fileservices.FileServices.GetEspURL(username, userPW);
  816. /**
  817. * Returns the path to the default Drop Zone
  818. *
  819. *
  820. * @return A string containing the path to the default Drop Zone.
  821. * If more than one Drop Zone
  822. * process is defined then the first found will
  823. * be returned; will return an empty string if a Drop Zone
  824. * cannot be found
  825. */
  826. EXPORT varstring GetDefaultDropZone() :=
  827. lib_fileservices.FileServices.GetDefaultDropZone();
  828. /**
  829. * Returns a dataset with full paths to all Drop Zones
  830. *
  831. *
  832. * @return A dataset containing all defined Drop Zone paths.
  833. * Will return an empty dataset if a Drop Zone
  834. * cannot be found
  835. */
  836. EXPORT dataset(FsDropZoneRecord) GetDropZones() :=
  837. lib_fileservices.FileServices.GetDropZones();
  838. END;