-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathftcl_copy.cpp
More file actions
66 lines (57 loc) · 1.99 KB
/
ftcl_copy.cpp
File metadata and controls
66 lines (57 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include "FitsbenchMain.h"
# include "FitsbenchItem.h"
# include "qassert.h"
using namespace std;
int FitsbenchMain::ftcl_copy_thunk_(ClientData raw, Tcl_Interp*interp,
int objc, Tcl_Obj*CONST objv[])
{
FitsbenchMain*eng = reinterpret_cast<FitsbenchMain*> (raw);
qassert(eng->tcl_engine_ == interp);
return eng->ftcl_copy_(objc, objv);
}
/*
* copy <work/name> <src>
*/
int FitsbenchMain::ftcl_copy_(int objc, Tcl_Obj*const objv[])
{
if (objc < 3) {
Tcl_AppendResult(tcl_engine_, "usage", 0);
return TCL_ERROR;
}
FitsbenchItem*src_item = item_from_name_(objv[2]);
if (src_item == 0) {
Tcl_AppendResult(tcl_engine_, "Source array not found", 0);
return TCL_ERROR;
}
WorkFolder::Image*item = workitem_from_name_(objv[1]);
if (item == 0) {
Tcl_AppendResult(tcl_engine_, "Work Folder not found", 0);
return TCL_ERROR;
}
DataArray*src = dynamic_cast<DataArray*> (src_item);
qassert(src);
int rc = item->copy_from_array(src);
if (rc < 0) {
Tcl_AppendResult(tcl_engine_, "Error copying array", 0);
return TCL_ERROR;
}
return TCL_OK;
}