-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <iostream>
#include <fstream>
-#include <stdlib.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
// purpose : Removes files listed in theFileList
//============================================================================
void SALOMEDS_Tool::RemoveTemporaryFiles(const std::string& theDirectory,
- const SALOMEDS::ListOfFileNames& theFiles,
+ const ListOfFiles& theFiles,
const bool IsDirDeleted)
{
std::string aDirName = theDirectory;
- int i, aLength = theFiles.length();
+ int i, aLength = theFiles.size();
for(i=1; i<=aLength; i++) {
std::string aFile(aDirName);
aFile += theFiles[i-1];
{
SALOMEDS::TMPFile*
PutFilesToStream(const std::string& theFromDirectory,
- const SALOMEDS::ListOfFileNames& theFiles,
- const SALOMEDS::ListOfFileNames& theFileNames,
+ const std::vector<std::string>& theFiles,
+ const std::vector<std::string>& theFileNames,
const int theNamesOnly)
{
- int i, aLength = theFiles.length();
+ int i, aLength = theFiles.size();
if(aLength == 0)
return (new SALOMEDS::TMPFile);
//Check if the file exists
if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero
- std::string aFullPath = aTmpDir + const_cast<char*>(theFiles[i].in());
+ std::string aFullPath = aTmpDir + theFiles[i];
if(!Exists(aFullPath)) continue;
#ifdef WIN32
std::ifstream aFile(aFullPath.c_str(), std::ios::binary);
aFileSize[i] = aFile.tellg();
aBufferSize += aFileSize[i]; //Add a space to store the file
}
- aFileNameSize[i] = strlen(theFileNames[i])+1;
+ aFileNameSize[i] = theFileNames[i].length()+1;
aBufferSize += aFileNameSize[i]; //Add a space to store the file name
aBufferSize += (theNamesOnly)?4:12; //Add 4 bytes: a length of the file name,
// 8 bytes: length of the file itself
for(i=0; i<aLength; i++) {
std::ifstream *aFile;
if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
- std::string aFullPath = aTmpDir + const_cast<char*>(theFiles[i].in());
+ std::string aFullPath = aTmpDir + theFiles[i];
if(!Exists(aFullPath)) continue;
#ifdef WIN32
aFile = new std::ifstream(aFullPath.c_str(), std::ios::binary);
aCurrentPos += 4;
//Copy the file name to the buffer
- memcpy((aBuffer + aCurrentPos), theFileNames[i], aFileNameSize[i]);
+ memcpy((aBuffer + aCurrentPos), theFileNames[i].c_str(), aFileNameSize[i]);
aCurrentPos += aFileNameSize[i];
if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
SALOMEDS::TMPFile*
SALOMEDS_Tool::PutFilesToStream(const std::string& theFromDirectory,
- const SALOMEDS::ListOfFileNames& theFiles,
+ const ListOfFiles& theFiles,
const int theNamesOnly)
{
- SALOMEDS::ListOfFileNames aFileNames(theFiles);
+ ListOfFiles aFileNames(theFiles);
return ::PutFilesToStream(theFromDirectory,theFiles,aFileNames,theNamesOnly);
}
SALOMEDS::TMPFile*
-SALOMEDS_Tool::PutFilesToStream(const SALOMEDS::ListOfFileNames& theFiles,
- const SALOMEDS::ListOfFileNames& theFileNames)
+SALOMEDS_Tool::PutFilesToStream(const ListOfFiles& theFiles,
+ const ListOfFiles& theFileNames)
{
return ::PutFilesToStream("",theFiles,theFileNames,0);
}
// function : PutStreamToFile
// purpose : converts the stream "theStream" to the files
//============================================================================
-SALOMEDS::ListOfFileNames_var
+SALOMEDS_Tool::ListOfFiles
SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
const std::string& theToDirectory,
const int theNamesOnly)
{
- SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
+ ListOfFiles aFiles;
if(theStream.length() == 0)
return aFiles;
//Copy the number of files in the stream
memcpy(&aNbFiles, aBuffer, sizeof(int));
- aFiles->length(aNbFiles);
+ aFiles.reserve(aNbFiles);
for(i=0; i<aNbFiles; i++) {
aFile.close();
aCurrentPos += aFileSize;
}
- aFiles[i] = CORBA::string_dup(aFileName);
+ aFiles.push_back(CORBA::string_dup(aFileName));
delete[] aFileName;
}
}
-