Commit 6fb7ef1dd5ad2c488069592ad2796b9838e77511

Authored by Hacene SI HADJ MOHAND
2 parents 5d98ad1c ffb71385

Merge branch 'master' into rm_6616

src/ParamOutputImpl/Download/CMakeLists.txt
... ... @@ -36,6 +36,7 @@ target_link_libraries(
36 36 ${LOG4CXX_LIBRARIES}
37 37 ${Boost_LIBRARY_DIR}/libboost_system.so
38 38 ${Boost_LIBRARY_DIR}/libboost_thread.so
  39 + ${Boost_LIBRARY_DIR}/libboost_filesystem.so
39 40 ${libcdf_LIBRARIES}
40 41 rt
41 42 Parameters
... ...
src/ParamOutputImpl/Download/DownloadOutput.cc
... ... @@ -788,10 +788,11 @@ std::string DownloadOutput::getFilePath(std::string extension, bool infoFile)
788 788  
789 789 filePath << "/";
790 790  
  791 + std::stringstream fileName;
791 792 if (_downloadProperties.getFileName().empty())
792   - filePath << "output-";
  793 + fileName << "output-";
793 794 else
794   - filePath << _downloadProperties.getFileName() << "-";
  795 + fileName << _downloadProperties.getFileName() << "-";
795 796  
796 797 //add parameters ids
797 798 bool firstParam = true;
... ... @@ -805,10 +806,10 @@ std::string DownloadOutput::getFilePath(std::string extension, bool infoFile)
805 806 }
806 807  
807 808 if (!firstParam)
808   - filePath << "_";
  809 + fileName << "_";
809 810 firstParam = false;
810 811  
811   - filePath << paramProperties->getOriginalId();
  812 + fileName << paramProperties->getOriginalId();
812 813  
813 814 //add indexes
814 815 for (auto index : paramProperties->getIndexDefList())
... ... @@ -816,10 +817,11 @@ std::string DownloadOutput::getFilePath(std::string extension, bool infoFile)
816 817 boost::replace_all(index, "[", "");
817 818 boost::replace_all(index, "]", "");
818 819 boost::replace_all(index, "*", "x");
819   - filePath << "_" << index;
  820 + fileName << "_" << index;
820 821 }
821 822 }
822 823  
  824 + std::stringstream fileNameSuffix;
823 825 if (!infoFile)
824 826 {
825 827 if ((_downloadProperties.getOutputStructure() != ONE_FILE) &&
... ... @@ -827,8 +829,8 @@ std::string DownloadOutput::getFilePath(std::string extension, bool infoFile)
827 829 (_parameterManager.getInputIntervals()->size() != 1))
828 830 {
829 831 //add interval index
830   - filePath << "_" << _currentTimeInterval->_ttName;
831   - filePath << "_" << _currentIntervalIndex;
  832 + fileNameSuffix << "_" << _currentTimeInterval->_ttName;
  833 + fileNameSuffix << "_" << _currentIntervalIndex;
832 834 }
833 835 else
834 836 {
... ... @@ -838,17 +840,25 @@ std::string DownloadOutput::getFilePath(std::string extension, bool infoFile)
838 840 double lStartTime = _currentTimeInterval->_startTime;
839 841 char buffer[TIMELENGTH];
840 842 Double2DD_Time(buffer, lStartTime);
841   - filePath << "_" << buffer;
  843 + fileNameSuffix << "_" << buffer;
842 844 }
843 845 else
844 846 {
845 847 //add TT name
846   - filePath << "_" << _currentTimeInterval->_ttName;
  848 + fileNameSuffix << "_" << _currentTimeInterval->_ttName;
847 849 }
848 850 }
849 851 }
850 852 else
851   - filePath << "_info";
  853 + fileNameSuffix << "_info";
  854 +
  855 + //check fileName size
  856 + if (fileName.str().size() + extension.size() + 1 + fileNameSuffix.str().size() > 100) {
  857 + filePath << fileName.str().substr(0,100-extension.size() - 1 - fileNameSuffix.str().size()) << fileNameSuffix.str();
  858 + }
  859 + else {
  860 + filePath << fileName.str() << fileNameSuffix.str();
  861 + }
852 862  
853 863 //add extension
854 864 filePath << ".";
... ...
src/ParamOutputImpl/Download/FileWriterASCIIAbstract.cc
... ... @@ -14,6 +14,9 @@
14 14 #include <iomanip>
15 15 #include <stdlib.h>
16 16  
  17 +#include <boost/filesystem.hpp>
  18 +#include <boost/functional/hash.hpp>
  19 +
17 20 namespace AMDA {
18 21 namespace ParamOutputImpl {
19 22 namespace Download {
... ... @@ -113,7 +116,12 @@ bool FileWriterASCIIAbstract::addParameter(ParamProperties* paramProp, AMDA::Com
113 116 _fieldInfoMap[paramProp->getOutputId()].componentsList.push_back(component);
114 117  
115 118 //temporary file for this parameter
116   - std::string paramFileName = _outputFilePath;
  119 + boost::filesystem::path p{_outputFilePath};
  120 + std::string paramFileName = p.parent_path().string();
  121 + paramFileName += boost::filesystem::path::preferred_separator;
  122 + boost::hash<std::string> string_hash;
  123 + paramFileName += std::to_string(string_hash(p.filename().string()));
  124 + //_outputFilePath;
117 125 paramFileName += "_";
118 126 paramFileName += paramProp->getOutputId();
119 127 _fieldInfoMap[paramProp->getOutputId()].filePath = paramFileName;
... ...