Page tree
Skip to end of metadata
Go to start of metadata

With the File System add-on, it is possible to read and write files (even incrementally), and to read and create directories.

Example File (Builder project Add-ons/FileSystem):

<your example path>\Add-ons\FileSystem\uml\fileSystemDyn.xml
<your example path>\Add-ons\FileSystem\uml\fileSystemStat.xml

Common Tasks Using the File System Adapter

Find below a table listing some common tasks you can use the File System Adapter for, and which action to use for which task.

TaskActionModeImportant ParametersComments
Write a complete file in one action.write  
  • If the file exists, it will be overwritten.
  • If the file does not exist, it will be created.
Replace part of a file.write positionWrites the data to the file beginning at the specified position. If the file does not exists you'll get the exception FSADM/8 (see Catching Errors).
Append data to a file.appendappend 
  • If the file exists, the given data will be appended.
  • If the file does not exist, it will be created.
Write a complete file line by line.append

overwrite

 

Use mode overwrite for all appends.

  • If the file exists, it will be overwritten.
  • If the file does not exist, it will be created.

overwrite will only be applied to the first append. All subsequent appends (e.g. in a loop) automatically get mode append.

Manipulate a file and process the file further (e.g. moving it).
  1. write or append
  2. close
  3. further processing
  Before processing the file further (e.g. moving it), close the file. Otherwise it may be locked.

Static versus Dynamic Requests

We distinct between static and dynamic requests.

  • Static means that the whole backend information (path and name) is defined in the component diagram and is not modified when called within an action. However, this information can be accessed within an action via the so called deployment macros. This is sometimes useful, e. g. when URL parameters must be calculated or known at runtime only (for details refer to Deployment Macros).
  • A dynamic call means that the necessary parameters are being specified during the execution of the activity. In the present case, a dynamic usage of the file system adapter means that parameters like the name of a file or a directory are not part of the component diagram, but rather specified in an action and passed on to the file system adapter as an input object. Read more on dynamic file system access on Dynamic File System Access.

Catching Errors

All errors thrown by the File System adapter can be caught as described in Catching Errors.

DomainError CodeDescription
FSADSM1Failed opening file.
FSADSM2No enough memory.
FSADSM3Position is invalid.
FSADSM4Failed reading file.
FSADSM5Request is unknown in the Filesystem repository.
FSADSM6Failed stating file.
FSADSM7The content is smaller than the write size.
FSADSM8Failed opening file.
FSADSM9Position is invalid.
FSADSM10Failed writing file.
FSADSM11Request is unknown in the Filesystem repository.
FSADSM12Status request is unknown in the Filesystem repository.
FSADSM13Failed stating file.
FSADSM14Failed renaming entry.
FSADSM15Remove request is unknown in the Filesystem repository.
FSADSM16Failed creating directory.
FSADSM17CreateDirectory request is unknown in the Filesystem repository.
FSADSM18Failed opening directory.
FSADSM19ReadDirectory request is unknown in the Filesystem repository.
FSADSM20Failed reading the directory.
FSADSM21Data missing for write request.
FSADSM22Failed creating file.
FSADSM23Failed stating entry for removal.
FSADSM24Request is unknown in the Filesystem repository.
FSADSM25Failed opening file.
FSADSM26Failed renaming entry.
FSADSM27Failed stating entry for renaming
FSADSM28Rename request is unknown in the Filesystem repository.
FSADSM29File is not open.
FSADSM30Failed closing file.
FSADSM31Failed getting exact file size. The real size may differ.
FSADSM32Name is empty.
FSADSM32Path '%s' is outside allowed base directory '%s'.