ConnectListAndGoAway:
PROCEDURE [hostName:
ROPE, Directory:
ROPE, Pattern:
ROPE] = {
ftpHandle: FTP.Handle;
remoteHerald: ROPE;
properties: FTP.PropertySet;
name, password: Rope.ROPE;
nameList: LIST OF REF listObject ← NIL;
enumProc:
PROCEDURE [h:
FTP.Handle] = {
create: BasicTime.GMT;
directory: ROPE;
name: ROPE;
version: ROPE;
item: REF listObject;
create ← h.GetDateProperty[prop: createDate, list: remote];
directory ← h.GetTextProperty[prop: directory, list: remote];
name ← h.GetTextProperty[prop: nameBody, list: remote];
version ← h.GetTextProperty[prop: version, list: remote];
item ← NEW[listObject ← [directory, name, version, create]];
nameList ← CONS[item, nameList];
};
[name, password] ← UserCredentials.Get[];
[h: ftpHandle, remoteHerald: remoteHerald] ← FTP.CreateFromName[hostName: hostName, localHerald: "Cedar FTP Calling"] ;
properties[createDate] ← TRUE;
properties[directory] ← TRUE;
properties[nameBody] ← TRUE;
properties[version] ← TRUE;
FTP.SetDesiredProperties[h: ftpHandle, props: properties, userDefinedProps: NIL];
FTP.SetTextProperty[ftpHandle, directory, Directory];
FTP.SetTextProperty[ftpHandle, nameBody, Pattern];
FTP.SetTextProperty[ftpHandle, userName, name];
FTP.SetTextProperty[ftpHandle, userPassword, password];
FTP.Enumerate[h: ftpHandle, noteFile: enumProc];
FTP.Destroy[ftpHandle];
};
ConnectRetrieveAndGoAway:
PROCEDURE [hostName:
ROPE, directory:
ROPE, file:
ROPE, version:
ROPE]
RETURNS [fileRope:
ROPE] = {
ftpHandle: FTP.Handle;
remoteHerald: ROPE;
properties: FTP.PropertySet;
name, password: Rope.ROPE;
nameList: LIST OF REF listObject ← NIL;
confirmProc:
FTP.ConfirmProc = {
PROCEDURE [h: Handle] RETURNS [confirm: BOOLEAN];
confirm ← TRUE;
};
transferProc:
FTP.TransferProc = {
PROCEDURE [h: Handle, stream: IO.STREAM];
DO
fileRope ← Rope.Concat[fileRope, stream.GetLineRope[ ! IO.EndOfStream => EXIT]];
ENDLOOP;
};
completeProc:
FTP.CompleteProc = {
PROCEDURE [h: Handle, ok: BOOLEAN];
};
[name, password] ← UserCredentials.Get[];
[h: ftpHandle, remoteHerald: remoteHerald] ← FTP.CreateFromName[hostName: hostName, localHerald: "Cedar FTP Calling"] ;
properties[createDate] ← TRUE;
properties[directory] ← TRUE;
properties[nameBody] ← TRUE;
properties[version] ← TRUE;
properties[size] ← TRUE;
FTP.SetDesiredProperties[h: ftpHandle, props: properties, userDefinedProps: NIL];
FTP.SetTextProperty[ftpHandle, directory, directory];
FTP.SetTextProperty[ftpHandle, nameBody, file];
FTP.SetTextProperty[ftpHandle, userName, name];
FTP.SetTextProperty[ftpHandle, userPassword, password];
FTP.SetTextProperty[ftpHandle, version, version];
FTP.Retrieve[h: ftpHandle, confirm: confirmProc, transfer: transferProc, complete: completeProc];
FTP.Destroy[ftpHandle];
};