2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2006 - INRIA - Allan CORNET
4 * Copyright (C) 2009 - DIGITEO - Allan CORNET
5 * Copyright (C) 2010 - DIGITEO - Antoine ELIAS
7 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
14 /*--------------------------------------------------------------------------*/
16 #include "function.hxx"
19 #include "filemanager.hxx"
20 #include "fileio_gw.hxx"
24 #include "sci_malloc.h"
26 #include "localization.h"
30 using namespace types;
32 /*--------------------------------------------------------------------------*/
33 Function::ReturnValue sci_fileinfo(typed_list &in, int _iRetCount, typed_list &out)
37 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "fileinfo", 1);
38 return Function::Error;
41 if (in[0]->isString() == false )
43 Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "fileinfo", 1);
44 return Function::Error;
49 Scierror(78, _("%s: Wrong number of output arguments: %d or %d expected.\n"), "fileinfo", 1, 2);
50 return Function::Error;
53 String* pS = in[0]->getAs<types::String>();
54 InternalType* iT = NULL;
57 if (pS->getCols() != 1)
60 pS = iT->getAs<types::String>();
62 int *piErr = new int[pS->getRows()];
63 double* pData = filesinfoW(pS->get(), pS->getRows(), piErr);
65 /* fileinfo returns [] for single non existing file to match the behavior
67 if (pS->getRows() == 1 && *piErr == -1)
69 out.push_back(Double::Empty());
73 Double *pOut = new Double(pS->getRows(), FILEINFO_ARRAY_SIZE);
80 Double* pErr = new Double(pS->getRows(), 1);
89 /*--------------------------------------------------------------------------*/