Changeset 619 for trunk/zoo-project/zoo-kernel/service_internal_otb.c
- Timestamp:
- Mar 30, 2015, 2:42:31 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal_otb.c
r618 r619 95 95 } 96 96 return str; 97 } 98 99 /** 100 * Write a file from value and length 101 * 102 * @param fname the file name 103 * @param val the value 104 * @param length the value length 105 */ 106 int writeFile(char* fname,char* val,int length){ 107 FILE* of=fopen(fname,"wb"); 108 if(of==NULL){ 109 return -1; 110 } 111 size_t ret=fwrite(val,sizeof(char),length,of); 112 if(ret<length){ 113 fprintf(stderr,"Write error occured!\n"); 114 fclose(of); 115 return -1; 116 } 117 fclose(of); 118 return 1; 97 119 } 98 120 … … 191 213 dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType); 192 214 }else{ 215 map* tmpPath=getMapFromMaps(m,"main","tmpPath"); 216 map* tmpSid=getMapFromMaps(m,"lenv","sid"); 193 217 map* tmpVal=getMapFromMaps(inputs,paramKey.c_str(),"mimeType"); 194 218 char file_ext[32]; 195 219 getFileExtension(tmpVal != NULL ? tmpVal->value : NULL, file_ext, 32); 196 220 if(type == ParameterType_InputImageList){ 197 values.push_back(test->value); 221 char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char)); 222 sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,0,file_ext); 223 int length=0; 224 map* tmpSize=getMap(test,"size"); 225 if(tmpSize!=NULL){ 226 length=atoi(tmpSize->value); 227 } 228 writeFile(val,test->value,length); 229 values.push_back(val); 230 free(val); 198 231 map* tmpLength=getMapFromMaps(inputs,paramKey.c_str(),"length"); 199 232 if(tmpLength!=NULL){ 200 233 int len=atoi(tmpLength->value); 234 maps* tmpI=getMaps(inputs,paramKey.c_str()); 201 235 for(int k=1;k<len;k++){ 202 char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));236 val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char)); 203 237 sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,k,file_ext); 204 FILE* of=fopen(val,"wb");205 int length=0;206 map* tmpSize=getMap(test,"size");238 length=0; 239 map* tmpV=getMapArray(tmpI->content,"value",k); 240 tmpSize=getMapArray(tmpI->content,"size",k); 207 241 if(tmpSize!=NULL){ 208 242 length=atoi(tmpSize->value); 209 243 } 210 fwrite(test->value,sizeof(char),length,of); 211 fclose(of); 244 writeFile(val,tmpV->value,length); 212 245 values.push_back(val); 213 246 free(val); … … 220 253 || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData 221 254 || type == ParameterType_InputFilename){ 222 map* tmpPath=getMapFromMaps(m,"main","tmpPath");223 map* tmpSid=getMapFromMaps(m,"lenv","sid");224 255 char tmp[1024]; 225 256 char* ext="json"; … … 227 258 char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+10)*sizeof(char)); 228 259 sprintf(val,"%s/Input_%s_%s.%s",tmpPath->value,s->name,tmpSid->value,file_ext); 229 FILE* of=fopen(val,"wb");230 260 int length=0; 231 261 map* tmpSize=getMap(test,"size"); … … 233 263 length=atoi(tmpSize->value); 234 264 } 235 fwrite(test->value,sizeof(char),length,of); 236 fclose(of); 265 writeFile(val,test->value,length); 237 266 238 267 if(strncasecmp(tmpVal->value,"application/zip",14)==0){
Note: See TracChangeset
for help on using the changeset viewer.