diff options
Diffstat (limited to 'lib/cosFileTransfer/src/CosFileTransfer_FileIterator_impl.erl')
-rw-r--r-- | lib/cosFileTransfer/src/CosFileTransfer_FileIterator_impl.erl | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/lib/cosFileTransfer/src/CosFileTransfer_FileIterator_impl.erl b/lib/cosFileTransfer/src/CosFileTransfer_FileIterator_impl.erl new file mode 100644 index 0000000000..2800c19d46 --- /dev/null +++ b/lib/cosFileTransfer/src/CosFileTransfer_FileIterator_impl.erl @@ -0,0 +1,157 @@ +%%---------------------------------------------------------------------- +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2000-2009. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%% +%%---------------------------------------------------------------------- +%% File : CosFileTransfer_FileIterator_impl.erl +%% Description : +%% +%% Created : 12 Sept 2000 +%%---------------------------------------------------------------------- +-module('CosFileTransfer_FileIterator_impl'). + + + + +%%---------------------------------------------------------------------- +%% Include files +%%---------------------------------------------------------------------- +-include("cosFileTransferApp.hrl"). + +%%---------------------------------------------------------------------- +%% External exports +%%---------------------------------------------------------------------- +-export([init/1, + terminate/2, + code_change/3, + handle_info/2]). + +%% Interface functions +-export([next_one/2, + next_n/3, + destroy/2]). + +%%---------------------------------------------------------------------- +%% Internal exports +%%---------------------------------------------------------------------- +-export([]). + +%%---------------------------------------------------------------------- +%% Records +%%---------------------------------------------------------------------- + +%%---------------------------------------------------------------------- +%% Macros +%%---------------------------------------------------------------------- + +%%====================================================================== +%% External functions +%%====================================================================== +%%---------------------------------------------------------------------- +%% Function : init/1 +%% Returns : {ok, State} | +%% {ok, State, Timeout} | +%% ignore | +%% {stop, Reason} +%% Description: Initiates the server +%%---------------------------------------------------------------------- +init([FileList]) -> + {ok, FileList}. + +%%---------------------------------------------------------------------- +%% Function : terminate/2 +%% Returns : any (ignored by gen_server) +%% Description: Shutdown the server +%%---------------------------------------------------------------------- +terminate(_Reason, _State) -> + ok. + +%%---------------------------------------------------------------------- +%% Function : code_change/3 +%% Returns : {ok, NewState} +%% Description: Convert process state when code is changed +%%---------------------------------------------------------------------- +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%%---------------------------------------------------------------------% +%% function : handle_info/2 +%% Arguments: +%% Returns : +%% Effect : +%%---------------------------------------------------------------------- +handle_info(Info, State) -> + case Info of + {'EXIT', _Pid, Reason} -> + {stop, Reason, State}; + _Other -> + {noreply, State} + end. + +%%====================================================================== +%% CosFileTransfer::FileIterator +%%====================================================================== +%%---------------------------------------------------------------------% +%% Function : next_one +%% Arguments : +%% Returns : {boolean(), FileWrapper} +%% Description: +%%---------------------------------------------------------------------- +next_one(_OE_This, []) -> + {reply, {false, + #'CosFileTransfer_FileWrapper'{the_file = corba:create_nil_objref(), + file_type = nfile}}, []}; +next_one(_OE_This, [FileWrapper]) -> + {reply, {true, FileWrapper}, []}; +next_one(_OE_This, [FileWrapper|Rest]) -> + {reply, {true, FileWrapper}, Rest}. + +%%---------------------------------------------------------------------% +%% Function : next_n +%% Arguments : HowMany - ulong() +%% Returns : {boolean(), FileWrapperList} +%% Description: +%%---------------------------------------------------------------------- +next_n(_OE_This, [], _) -> + {reply, {false, []}, []}; +next_n(_OE_This, FileWrapperList, HowMany) when HowMany > length(FileWrapperList) -> + {reply, {true, FileWrapperList}, []}; +next_n(_OE_This, FileWrapperList, HowMany) -> + {reply, {true, lists:sublist(FileWrapperList, HowMany)}, + lists:nthtail(HowMany, FileWrapperList)}. + +%%---------------------------------------------------------------------% +%% Function : destroy +%% Arguments : - +%% Returns : - +%% Description: +%%---------------------------------------------------------------------- +destroy(_OE_This, State) -> + {stop, normal, ok, State}. + + +%%====================================================================== +%% Internal functions +%%====================================================================== + + + +%%====================================================================== +%% END OF MODULE +%%====================================================================== |