1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 * 14 */ 15 /*--------------------------------------------------------------------------*/ 16 #include "filemanager.hxx" 17 #include "file.hxx" 18 19 extern "C" 20 { 21 #include "addfile.h" 22 #include "charEncoding.h" 23 #include "sci_malloc.h" 24 } 25 26 /*--------------------------------------------------------------------------*/ C2F(addfile)27void C2F(addfile)(int *fd, FILE *fa, int *swap2, int *type, int *mode, char *filename, int *ierr) 28 { 29 wchar_t* wcsFilename = to_wide_string(filename); 30 types::File* pFile = new types::File(); 31 32 pFile->setFilename(std::wstring(wcsFilename)); 33 34 if (*type == 2) 35 { 36 pFile->setFileDesc(fa); 37 pFile->setFileModeAsInt(*mode); 38 } 39 else if (*type == -1) 40 { 41 pFile->setFileDesc(stdin); 42 } 43 else if (*type == -2) 44 { 45 pFile->setFileDesc(stdout); 46 } 47 else if (*type == -3) 48 { 49 pFile->setFileDesc(stderr); 50 } 51 else 52 { 53 pFile->setFileDesc((FILE*)0); 54 pFile->setFileFortranMode(*mode); 55 } 56 57 pFile->setFileSwap(*swap2); 58 pFile->setFileType(*type); 59 60 FileManager::addFile(pFile); 61 62 *ierr = 0; 63 64 FREE(wcsFilename); 65 } 66 /*--------------------------------------------------------------------------*/ 67 68