Skip to main content

Calling Adapter Methods from the Business Operation

Calling Adapter Methods from the Business Operation

Your business operation class can use the following instance methods of EnsLib.File.OutboundAdapterOpens in a new tab.

CreateTimestamp()
ClassMethod CreateTimestamp(pFilename As %String = "",
                            pSpec As %String = "_%C") As %String

Using the pFilename string as a starting point, incorporate the time stamp specifier provided in pSpec and return the resulting string. The default time stamp specifier is _%C which provides the full date and time down to the millisecond.

For full details about time stamp conventions, see “Time Stamp Specifications for Filenames” in Configuring Ensemble Productions.

Delete()
Method Delete(pFilename As %String) As %Status

Deletes the file.

Exists()
Method Exists(pFilename As %String) As %Boolean

Returns 1 (True) if the file exists, 0 (False) if it does not.

GetStream()
Method GetStream(pFilename As %String,
                 ByRef pStream As %AbstractStream = {$$$NULLOREF})
                 As %Status

Gets a stream from the file.

NameList()
Method NameList(Output pFileList As %ListOfDataTypes,
                pWildcards As %String = "*",
                pIncludeDirs As %Boolean = 0) As %Status

Get a list of files in the directory specified by the FilePath setting. The filenames are returned in a %ListOfDataTypesOpens in a new tab object. Each entry in the list is a semicolon-separated string containing:

Filename;Type;Size;DateCreated;DateModified;FullPathName

PutLine()
Method PutLine(pFilename As %String, pLine As %String) As %Status

Writes a string to the file and appends to the string the characters specified in the LineTerminator property. By default, the LineTerminator is a carriage return followed by a line feed (ASCII 13, ASCII 10).

If your operating system requires a different value for the LineTerminator property, set the value in the OnInit() method of the business operation. For example:

 Method OnInit() As %Status
  {
      Set ..Adapter.LineTerminator="$C(10)"
      Quit $$$OK
  }

You can also make the property value to be dependent on the operating system:

 Set ..Adapter.LineTerminator="$Select($$$isUNIX:$C(10),1:$C(13,10))"

PutString()
Method PutString(pFilename As %String, pData As %String) As %Status

Writes a string to the file.

PutStream()
Method PutStream(pFilename As %String,
                 pStream As %Stream,
                 ByRef pLen As %Integer = -1) As %Status

Writes a stream to the file.

Rename()
Method Rename(pFilename As %String,
              pNewFilename As %String,
              pNewPath As %String = "") As %Status

Renames the file in the current path or moves it to the path specified by pNewPath.


FeedbackOpens in a new tab