X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FContainer%2FSALOME_FileTransfer_i.cxx;h=f83d9de95c00105dd6badcba08444fd09d1cd1c2;hb=3ce0546302001755828c8476425a60c6ab61ac92;hp=036fc5b6acb05a6a84a341e17978f73b9efe44df;hpb=e6bfea36374791cd31c274a2f97df90dc60ddaf3;p=modules%2Fkernel.git diff --git a/src/Container/SALOME_FileTransfer_i.cxx b/src/Container/SALOME_FileTransfer_i.cxx index 036fc5b6a..f83d9de95 100644 --- a/src/Container/SALOME_FileTransfer_i.cxx +++ b/src/Container/SALOME_FileTransfer_i.cxx @@ -1,32 +1,38 @@ - -// Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : SALOME_FileTransfer_i.cxx // Author : Paul RASCLE, EDF // Module : SALOME // $Header$ - +// #include "SALOME_FileTransfer_i.hxx" #include "utilities.h" +/*! \class fileTransfer_i + \brief A class to manage file transfer in SALOME + +*/ + //============================================================================= /*! * Default constructor, @@ -35,7 +41,6 @@ fileTransfer_i::fileTransfer_i() { - MESSAGE("fileTransfer_i::fileTransfer_i"); _fileKey=1; } @@ -47,22 +52,21 @@ fileTransfer_i::fileTransfer_i() fileTransfer_i::~fileTransfer_i() { - MESSAGE("fileTransfer_i::~fileTransfer_i"); } //============================================================================= -/*! - * CORBA method: try to open the file given. If the file is readable, return +/*! \brief open the given file + * + * CORBA method: try to open the file. If the file is readable, return * a positive integer else return 0; - * \param fileName path to the file to be transfered + * \param fileName path to the file to be transferred * \return fileId = positive integer > 0 if open OK. */ //============================================================================= CORBA::Long fileTransfer_i::open(const char* fileName) { - MESSAGE(" fileTransfer_i::open " << fileName); int aKey = _fileKey++; _ctr=0; FILE* fp; @@ -76,7 +80,8 @@ CORBA::Long fileTransfer_i::open(const char* fileName) } //============================================================================= -/*! +/*! \brief close a file + * * CORBA method: close the file associated to the fileId given at open. * \param fileId got in return from open method */ @@ -84,17 +89,23 @@ CORBA::Long fileTransfer_i::open(const char* fileName) void fileTransfer_i::close(CORBA::Long fileId) { - MESSAGE("fileTransfer_i::close"); FILE* fp; if (! (fp = _fileAccess[fileId]) ) { INFOS(" no FILE structure associated to fileId " <replace(nbRed, nbRed, buf, 1); // 1 means give ownership + size_t nbRed = fread(buf, sizeof(CORBA::Octet), FILEBLOCK_SIZE, fp); + //SCRUTE(nbRed); + aBlock->replace((CORBA::ULong)nbRed, (CORBA::ULong)nbRed, buf, 1); // 1 means give ownership return aBlock; } +/*! \brief open the given file in write mode (for copy) + * + * CORBA method: try to open the file. If the file is writable, + * return a positive integer else return 0; + * \param fileName path to the file to be transferred + * \return fileId = positive integer > 0 if open OK. + */ +CORBA::Long fileTransfer_i::openW(const char* fileName) +{ + int aKey = _fileKey++; + _ctr=0; + FILE* fp; + if ((fp = fopen(fileName,"wb")) == NULL) + { + INFOS("file " << fileName << " is not writable"); + return 0; + } + _fileAccess[aKey] = fp; + return aKey; +} + +/*! \brief put a data block for copy into a file + * + * CORBA method: put a block of data into the file associated to the fileId + * given at openW. + * \param fileId got in return from openW method + * \param block an octet sequence to copy into opened file + */ +void fileTransfer_i::putBlock(CORBA::Long fileId, const Engines::fileBlock& block) +{ + FILE* fp; + if (! (fp = _fileAccess[fileId]) ) + { + INFOS(" no FILE structure associated to fileId " <