File.ecl 53 KB

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