Dynamic File System Access
This page explains the Filesystem Adapter in Bridge context. If you were looking for the same information regarding the PAS Designer, refer to Filesystem Adapter in the Designer guide.
Dynamic usage of an adapter means that all necessary parameters are specified during the execution of an activity. Specifications from the component diagram are used as defaults, but can be overwritten.
In case of dynamic usage of the file system adapter file this concerns the location of the file or directory. Path and file name are specified and passed on to the adapter within the activity diagram.
The path or file name has to be fully qualified and must be passed on as an input parameter called name (in the present example an implicit mapping of the object buffer node fileName to the input pin name takes place):
Figure: Dynamic Reading of a File
In the example above the forward slash "/" is used in the action script specify file name within the path of the filename. This also works for Windows systems.
When using the Windows style with backward slashes "\" you have to be aware that you have escape this character. The escape character is also the "\".
To avoid this, use forward slashes with Windows as well.
So in the example above it would be: .\\tmp\\TestDirectoryDyn\\testFile_dyn.txt
. When hen accessing network drives via UNC (\\computername\sharedfolder\resource
) be aware that you have to escape every instance of "\
" so it would be: \\\\computername\\sharedfolder\\resource)
.
Directory Alias and Dynamic File Access
You can use a directory alias to define a base directory and a default encoding for the File System Adapter. The file name parameter will then be treated as a path relative to the base directory, the default encoding can be overridden per adapter call.
Figure: Dynamic Reading of a File with Directory Alias
The File System Adapter call Read a Line Dynamically with Directory Alias uses a directory alias to define a base directory (./tmp
in this case). Action Specify File Name adds to the base directory so that the full path will be ./tmp/testDirectoryDyn/testFile_dyn.txt
. Jumping out of the base directory by ../../aDirectory
tricks is impossible. The base directory can be changed in the service settings on the Bridge, however.
Action Specify Encoding overwrites the default encoding of directory alias TempDirectory (which is UTF-8) with ISO-8859-1.
Related Pages: