File.ecl 55 KB

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