[591] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Matlab Rappture Library Source |
---|
| 4 | * |
---|
[597] | 5 | * [err] = rpLibPutFile(libHandle,path,fileName,compress,append) |
---|
[591] | 6 | * |
---|
| 7 | * ====================================================================== |
---|
| 8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
| 9 | * Copyright (c) 2004-2007 Purdue Research Foundation |
---|
| 10 | * |
---|
| 11 | * See the file "license.terms" for information on usage and |
---|
| 12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 13 | * ====================================================================== |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "RpMatlabInterface.h" |
---|
| 17 | |
---|
| 18 | /**********************************************************************/ |
---|
[597] | 19 | // METHOD: [err] = rpLibPutFile (libHandle,path,fileName,compress,append) |
---|
[591] | 20 | /// Set the value of a node. |
---|
| 21 | /** |
---|
| 22 | * Clients use this to set the value of a node to the contents of a file. |
---|
| 23 | * If the path is not specified, it sets the value for the root node. |
---|
| 24 | * Otherwise, it sets the value for the element specified |
---|
| 25 | * by the path. The value is treated as the text within the |
---|
| 26 | * tag at the tail of the path. |
---|
| 27 | * |
---|
| 28 | * FileName is the name of the file to import into the rappture object |
---|
[597] | 29 | * Compress is an integer telling if you want the data compressed (use 1) |
---|
| 30 | * or uncompressed (use 0). |
---|
[591] | 31 | * Append is an integer telling if this new data should overwrite |
---|
| 32 | * (use 0) or be appended (use 1) to previous data in this node. |
---|
| 33 | * |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 37 | int nrhs, const mxArray *prhs[]) |
---|
| 38 | { |
---|
| 39 | int libIndex = 0; |
---|
| 40 | unsigned int append = 0; |
---|
[597] | 41 | unsigned int compress = 0; |
---|
[591] | 42 | int err = 1; |
---|
| 43 | RpLibrary* lib = NULL; |
---|
| 44 | std::string path = ""; |
---|
| 45 | std::string fileName = ""; |
---|
| 46 | |
---|
| 47 | /* Check for proper number of arguments. */ |
---|
[597] | 48 | if (nrhs != 5) { |
---|
| 49 | mexErrMsgTxt("Five inputs required."); |
---|
[591] | 50 | } |
---|
| 51 | |
---|
| 52 | libIndex = getIntInput(prhs[0]); |
---|
| 53 | path = getStringInput(prhs[1]); |
---|
| 54 | fileName = getStringInput(prhs[2]); |
---|
[597] | 55 | compress = (unsigned int) getIntInput(prhs[3]); |
---|
[591] | 56 | append = (unsigned int) getIntInput(prhs[4]); |
---|
| 57 | |
---|
| 58 | /* Call the C++ subroutine. */ |
---|
| 59 | if ( (libIndex > 0) && (!path.empty()) ) { |
---|
[1085] | 60 | lib = (RpLibrary*) getObject_Void(libIndex); |
---|
[591] | 61 | |
---|
| 62 | if (lib) { |
---|
[597] | 63 | lib->putFile(path,fileName,compress,append); |
---|
[591] | 64 | err = 0; |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | plhs[0] = mxCreateDoubleScalar(err); |
---|
| 69 | |
---|
| 70 | return; |
---|
| 71 | } |
---|