cosfiletransfer_directory_impl.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 451 行 · 第 1/2 页

ERL
451
字号
%%----------------------------------------------------------------------%% ``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 via the world wide web 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.%% %% The Initial Developer of the Original Code is Ericsson Utvecklings AB.%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings%% AB. All Rights Reserved.''%% %%     $Id$%% %%----------------------------------------------------------------------%% File        : CosFileTransfer_Directory_impl%% Description : %%%% Created     : 12 Sept 2000%%-----------------------------------------------------------------------module('CosFileTransfer_Directory_impl').%%----------------------------------------------------------------------%% Include files%%-----------------------------------------------------------------------include_lib("orber/include/corba.hrl").-include_lib("orber/src/orber_iiop.hrl").-include_lib("cosProperty/include/CosPropertyService.hrl").-include("cosFileTransferApp.hrl").%%----------------------------------------------------------------------%% External exports%%-----------------------------------------------------------------------export([init/1,	 terminate/2]).%% Interface functions-export([list/3]). %% Inherited CosFileTransfer::File-export(['_get_name'/2, 	 '_get_complete_file_name'/2, 	 '_get_parent'/2,	 '_get_associated_session'/2]). %% Inherited CosPropertyService::PropertySetDef-export([get_allowed_property_types/2, 	 get_allowed_properties/2, 	 define_property_with_mode/5,	 define_properties_with_modes/3, 	 get_property_mode/3, 	 get_property_modes/3,	 set_property_mode/4, 	 set_property_modes/3]). %% Inherited CosPropertyService::PropertySet-export([define_property/4, 	 define_properties/3, 	 get_number_of_properties/2,	 get_all_property_names/3, 	 get_property_value/3, 	 get_properties/3,	 get_all_properties/3, 	 delete_property/3, 	 delete_properties/3,	 delete_all_properties/2, 	 is_property_defined/3]). %%----------------------------------------------------------------------%% Internal exports%%----------------------------------------------------------------------%%----------------------------------------------------------------------%% Records%%-----------------------------------------------------------------------record(state, {property, 		name, 		completeName, 		parent, 		assocSession}).%%----------------------------------------------------------------------%% Macros%%-----------------------------------------------------------------------define(create_InitState(Pr, N, C, Pa, A),	#state{property     = Pr,	       name         = N,	       completeName = C,	       parent       = Pa,	       assocSession = A}).-define(get_PropertyRef(S),     S#state.property).-define(get_Name(S),            S#state.name).-define(get_CompleteName(S),    S#state.completeName).-define(get_Parent(S),          S#state.parent).-define(get_AssocSession(S),    S#state.assocSession).%%======================================================================%% External functions%%======================================================================%%----------------------------------------------------------------------%% Function   : init/1%% Returns    : {ok, State}          |%%              {ok, State, Timeout} |%%              ignore               |%%              {stop, Reason}%% Description: Initiates the server%%----------------------------------------------------------------------init([Name, CompleteName, Parent, AssocSession]) ->    PropTypes = [tk_long, tk_boolean],    %% WARNING if the order of the properties is changed so must    %% get_all_properties/3 in this module be as well!    PropDefs = [#'CosPropertyService_PropertyDef'		{property_name  = "num_children", 		 property_value = #any{typecode=tk_long, value=0}, 		 property_mode  = fixed_readonly},		#'CosPropertyService_PropertyDef'		{property_name  = "is_directory", 		 property_value = #any{typecode=tk_boolean, value=true}, 		 property_mode  = fixed_readonly}],    Prop = cosProperty:create_static_SetDef(PropTypes, PropDefs),    {ok, ?create_InitState(Prop, Name, CompleteName, Parent, AssocSession)}.%%----------------------------------------------------------------------%% Function   : terminate/2%% Returns    : any (ignored by gen_server)%% Description: Shutdown the server%%----------------------------------------------------------------------terminate(_Reason, _State) ->    ok.%%======================================================================%% CosFileTransfer::Directory%%======================================================================%%----------------------------------------------------------------------%% Function   : list%% Arguments  : Max - ulong()%% Returns    : {ok, FileList, FileIterator}%% Description: %%----------------------------------------------------------------------list(OE_This, State, Max) ->    case 'CosFileTransfer_FileTransferSession':	oe_orber_get_content(?get_AssocSession(State), ?get_CompleteName(State), 			     OE_This) of	[] ->	    {reply, {ok, [], corba:create_nil_objref()}, State};	FileList when length(FileList) > Max ->	    {reply, 	     {ok, lists:sublist(FileList, Max), 	     'CosFileTransfer_FileIterator':oe_create([lists:nthtail(Max, 								     FileList)])}, 	    State};	FileList ->	    {reply, {ok, FileList, corba:create_nil_objref()}, State}    end.%%======================================================================%% CosFileTransfer::File%%======================================================================%%---------------------------------------------------------------------%%% Function   : '_get_name'%% Arguments  : -%% Returns    : CosFileTransfer::FileName - string%% Description: %%----------------------------------------------------------------------'_get_name'(_OE_This, State) ->    {reply, ?get_Name(State), State}.%%---------------------------------------------------------------------%%% Function   : '_get_complete_file_name'%% Arguments  : -%% Returns    : CosFileTransfer::FileNameList - a list of strings's%% Description: %%----------------------------------------------------------------------'_get_complete_file_name'(_OE_This, State) ->    {reply, ?get_CompleteName(State), State}.%%---------------------------------------------------------------------%%% Function   : '_get_parent'%% Arguments  : -%% Returns    : CosFileTransfer::Directory%% Description: %%----------------------------------------------------------------------'_get_parent'(_OE_This, State) ->    {reply, ?get_Parent(State), State}.%%---------------------------------------------------------------------%%% Function   : '_get_associated_session'%% Arguments  : -%% Returns    : CosFileTransfer::FileTransferSession%% Description: %%----------------------------------------------------------------------'_get_associated_session'(_OE_This, State) ->    {reply, ?get_AssocSession(State), State}.%%======================================================================%% CosPropertyService::PropertySetDef%%======================================================================%%---------------------------------------------------------------------%%% Function   : get_allowed_property_types%% Arguments  : -%% Returns    : See cosProperty application.%% Description: %%----------------------------------------------------------------------get_allowed_property_types(_OE_This, State) ->    {reply, 'CosPropertyService_PropertySetDef':      get_allowed_property_types(?get_PropertyRef(State)), State}.%%---------------------------------------------------------------------%%% Function   : get_allowed_properties%% Arguments  : -%% Returns    : See cosProperty application.%% Description: %%----------------------------------------------------------------------get_allowed_properties(_OE_This, State) ->    {reply, 'CosPropertyService_PropertySetDef':     get_allowed_properties(?get_PropertyRef(State)), State}.%%---------------------------------------------------------------------%%% Function   : define_property_with_mode

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?