100
100
%% Description: Initiates the server
101
101
%%----------------------------------------------------------------------
102
init(['FTP', Host, Port, User, Password, Account, Protocol, Timeout]) ->
102
init(['FTP', Host, Port, User, Password, _Account, Protocol, Timeout]) ->
103
103
{ok, Pid} = ftp:open(Host, Port, []),
104
104
ok = ftp:user(Pid, User, Password),
105
105
{ok, PWD} = ftp:pwd(Pid),
106
106
{Connection, ProtocolSupport} = setup_local(Protocol),
107
107
{ok, ?create_InitState(ProtocolSupport, Pid, 'FTP',
108
108
PWD, ftp, Connection, Protocol, Timeout)};
109
init([{'NATIVE', Mod}, Host, Port, User, Password, Account, Protocol, Timeout]) ->
109
init([{'NATIVE', Mod}, Host, Port, User, Password, _Account, Protocol, Timeout]) ->
110
110
{ok, Pid} = Mod:open(Host, Port),
111
111
ok = Mod:user(Pid, User, Password),
112
112
{ok, PWD} = Mod:pwd(Pid),
120
120
%% Returns : any (ignored by gen_server)
121
121
%% Description: Shutdown the server
122
122
%%----------------------------------------------------------------------
123
terminate(Reason, State) ->
123
terminate(_Reason, State) ->
124
124
case ?get_MyType(State) of
126
126
catch ssl:close(?get_Connection(State));
134
134
%% Returns : {ok, NewState}
135
135
%% Description: Convert process state when code is changed
136
136
%%----------------------------------------------------------------------
137
code_change(OldVsn, State, Extra) ->
137
code_change(_OldVsn, State, _Extra) ->
140
140
%%---------------------------------------------------------------------%
166
166
%%----------------------------------------------------------------------
167
'_get_protocols_supported'(OE_This, State) ->
167
'_get_protocols_supported'(_OE_This, State) ->
168
168
{reply, ?get_Protocols(State), State}.
170
170
%%----------------------------------------------------------------------
175
175
%%----------------------------------------------------------------------
176
set_directory(OE_This, State, Directory) when ?is_FTP(State); ?is_NATIVE(State) ->
176
set_directory(_OE_This, State, Directory) when ?is_FTP(State); ?is_NATIVE(State) ->
177
177
Mod = ?get_Module(State),
178
178
Path = filename:join('CosFileTransfer_Directory':
179
179
'_get_complete_file_name'(Directory)),
244
244
get_file(OE_This, State, FileNameList) when ?is_FTP(State);
245
245
?is_NATIVE(State) ->
246
246
case check_type(OE_This, State, filename:join(FileNameList)) of
247
{ndirectory, Listing} ->
247
{ndirectory, _Listing} ->
249
249
#'CosFileTransfer_FileWrapper'{the_file =
250
250
cosFileTransferApp:
251
251
create_dir(OE_This,
254
253
file_type = ndirectory},
274
273
%%----------------------------------------------------------------------
275
delete(OE_This, State, File) when ?is_FTP(State); ?is_NATIVE(State) ->
274
delete(_OE_This, State, File) when ?is_FTP(State); ?is_NATIVE(State) ->
276
275
Mod = ?get_Module(State),
278
277
case 'CosPropertyService_PropertySet':
336
335
case which_FTS_type(OE_This, SrcFile, DestFile) of
337
336
{source, TargetFTS} ->
338
337
source_FTS_operation(State, SrcFile, DestFile, transfer, 0, TargetFTS);
339
{target, SourceFTS} ->
338
{target, _SourceFTS} ->
340
339
target_FTS_operation(State, SrcFile, DestFile, send, 0)
374
373
case which_FTS_type(OE_This, SrcFile, DestFile) of
375
374
{source, TargetFTS} ->
376
375
source_FTS_operation(State, SrcFile, DestFile, append, 0, TargetFTS);
377
{target, SourceFTS} ->
376
{target, _SourceFTS} ->
378
377
target_FTS_operation(State, SrcFile, DestFile, append, 0)
380
append(OE_This, State, SrcFile, DestFile) ->
379
append(_OE_This, _State, _SrcFile, _DestFile) ->
381
380
corba:raise(#'NO_IMPLEMENT'{completion_status=?COMPLETED_NO}).
405
404
{reply, ok, State};
406
405
{source, TargetFTS} ->
407
406
source_FTS_operation(State, SrcFile, DestFile, insert, Offset, TargetFTS);
408
{target, SourceFTS} ->
407
{target, _SourceFTS} ->
409
408
target_FTS_operation(State, SrcFile, DestFile, insert, Offset)
411
insert(OE_This, State, SrcFile, DestFile, Offset) ->
410
insert(_OE_This, _State, _SrcFile, _DestFile, _Offset) ->
412
411
corba:raise(#'NO_IMPLEMENT'{completion_status=?COMPLETED_NO}).
420
419
%%----------------------------------------------------------------------
421
logout(OE_This, State) when ?is_FTP(State); ?is_NATIVE(State) ->
420
logout(_OE_This, State) when ?is_FTP(State); ?is_NATIVE(State) ->
422
421
Mod = ?get_Module(State),
423
422
catch Mod:close(?get_Server(State)),
424
423
{stop, normal, ok, State}.
438
437
Mod = ?get_Module(State),
439
438
FileNameList = filename:split(?get_CurrentDir(State)),
440
439
case Mod:nlist(?get_Server(State), ?get_CurrentDir(State)) of
442
441
{reply, cosFileTransferApp:create_dir(OE_This, FileNameList),
444
443
{error, epath} ->
465
464
Mod = ?get_Module(State),
466
465
case Mod:nlist(?get_Server(State), filename:join(FileNameList)) of
468
create_content(Listing, OE_This, State, Parent);
467
create_content(Listing, OE_This, State, Parent, FileNameList);
469
468
{error, epath} ->
470
469
{reply, [], State};
645
644
%%----------------------------------------------------------------------
646
create_content(Listing, OE_This, State, Parent) ->
645
create_content(Listing, OE_This, State, Parent, PathList) ->
647
646
create_content(string:tokens(Listing, ?SEPARATOR), OE_This,
647
State, Parent, PathList, []).
650
create_content([], OE_This, State, Parent, Acc) ->
649
create_content([], _OE_This, State, _Parent, _PathList, Acc) ->
651
650
{reply, Acc, State};
652
create_content([H|T], OE_This, State, Parent, Acc) ->
653
case check_type(OE_This, State, H) of
651
create_content([H|T], OE_This, State, Parent, PathList, Acc) ->
652
FullPathList = PathList ++[filename:basename(H)],
653
case check_type(OE_This, State, filename:join(FullPathList)) of
655
create_content(T, OE_This, State, Parent,
655
create_content(T, OE_This, State, Parent, PathList,
656
656
[#'CosFileTransfer_FileWrapper'
657
657
{the_file = cosFileTransferApp:create_file(OE_This,
660
660
file_type = nfile}|Acc]);
661
{ndirectory, Members} ->
662
create_content(T, OE_This, State, Parent,
661
{ndirectory, _Members} ->
662
create_content(T, OE_This, State, Parent, PathList,
663
663
[#'CosFileTransfer_FileWrapper'
664
664
{the_file = cosFileTransferApp:create_dir(OE_This,
667
667
file_type = ndirectory}|Acc]);
766
766
%%----------------------------------------------------------------------
767
target_FTS_operation(State, SrcFile, DestFile, Op, Offset) ->
767
target_FTS_operation(State, _SrcFile, DestFile, Op, Offset) ->
768
768
Mod = ?get_Module(State),
769
769
DestName = 'CosFileTransfer_File':'_get_complete_file_name'(DestFile),
770
770
TempName = cosFileTransferApp:create_name("TemporaryDestFile"),
944
944
%% Furthermore, no need for traversing Listings etc.
945
945
%%----------------------------------------------------------------------
946
check_type(OE_This, State, FullName) when ?is_FTP(State); ?is_NATIVE(State) ->
946
check_type(_OE_This, State, FullName) when ?is_FTP(State); ?is_NATIVE(State) ->
947
947
Mod = ?get_Module(State),
949
949
case Mod:nlist(?get_Server(State), FullName) of
972
972
#'CosFileTransfer_RequestFailureException'
973
973
{reason="Unknown error."}}, State}
983
DirName = filename:dirname(FullName),
984
case Mod:nlist(?get_Server(State), DirName) of
985
{ok, Listing} when length(Listing) > 0->
986
Members = string:tokens(Listing, ?SEPARATOR),
987
case lists:member(FullName, Members) of
991
BName = filename:basename(FullName),
992
case lists:member(BName, Members) of
980
1003
case Mod:cd(?get_Server(State), FullName) of