AccessFile method

Accesses an eRoom file using an Extension File Access (EFA) object.

This method provides a callback mechanism through which a user-defined EFA is provided with access to a file in the eRoom file system. This method is the same as the AccessFile2 method, except that no optional arguments are passed to the EFA.

For information on creating EFA's, refer to the Remarks section below.

Syntax


C++
HRESULT AccessFile(
   IDispatch*
MyEFA,
   SAFEARRAY(VARIANT) ArgumentArray)
Scripting languages
Object.AccessFile(
   MyEFA as IDispatch,
   ArgumentArray as
SAFEARRAY(VARIANT))

Parameters


pEFA

The EFA for accessing the eRoom file.

ArgumentArray

An array of optional parameters.

Return value


C++

The return code.

Scripting languages

None.

Remarks


When you call the ::AccessFile() method and provide your Extension File Access Object (EFA) your EFA's "AccessFileImpl" method is called via IDispatch and provided with the UNC filepath and safearray that contains optional arguments if specified in the IERUFileAccess::AccessFile() method.

Example ASP-based extension file access object

The following is an example EFA object:

' EFA object that uses test file object in its ::AccessFileImpl() method
Class eRoomSampleEFA_GetFSOTextFile
'Reference to the object we'll create in AccessFile()
Private m_TextFileObject
'GetTextFileObject() -- Return the test file object
Function GetTextFileObject()
set GetTextFileObject=m_TextFileObject
End Function
'AccessFile() -- Called by eRoom in response to a call
'   SAAPI AccessFile() method.
Function AccessFileImpl(filename, args)
dim fso
dim arg
        ' we don't use optional args in this example...
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set m_TextFileObject=fso.OpenTextFile(filename, 1, 0, 0)   '## Open the file readonly
End Function
'If your object requires some initilization
'   or cleanup, you can add a constructor/destructor
'   Always create an object that cleans up after itself
'   when it is destroyed.
' Sub Class_Initialize()
' End Sub
' Sub Class_Terminate()
' End Sub
End Class

'## eRoom Embedded Viewer Class
'  This object implements a GenerateBody() method that is called by
'  eRoom to generate the body portion of the eRoom page for the item
'  represented by the IERUCustomContext object that is provided.
Class eRoomSample_TextViewer
'## eRoom Page Body Generation function
' Generates the body of the eRoom page for file by
' reading the text file from the eroom file system, html encoding it,
' and writing it to response.
function GenerateBody(Context)
dim s
dim ofile
'Create an Extension File Access object to gain access to the file
dim EFA : Set EFA = new eRoomSampleEFA_GetFSOTextFile
'Access the file in the eRoom file system.
' The EFA object's ::AccessFile() method is called by eRoom on your
'  behalf as a result of passing the EFA to the SAAPI AccessFile() method.
'  Note that an optional array of arguments can be passed to
'  ::AccessFile() and they will be passed along in the form of a
'  safearray to your ::AccessFileImpl() method.
call Context.Item.AccessFile(EFA, "First Optional", "Second Optional")  'optional args get passed into your EFA object as args safearray.
'Get the ITextStream object from our ASP defined File Access Object
set ofile = EFA.GetTextFileObject()
'## Display the contents of the file in a table.  Use the table to add padding
%><TABLE border=0 cellPadding=5 cellSpacing=5 width="100%">
<tr><td>
<div class=user><code>
<%
 do while not ofile.AtEndOfStream
'## Read the next line of the file.
     s = ofile.ReadLine
     '## Encode the current line and write to response
     %>
     <%=Server.HTMLEncode(s)%><br>
     <%     loop
%></code></div>
</td></tr>
</table>
<%
 '## Close the file.
 ofile.Close
 set ofile = nothing
end function
End Class
%>

Home

Applies to

IERUFileAccess