GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


A Paste by Anonymous
1
 
attachment.open(attach_path.c_str(),ifstream::in|ifstream::binary|ifstream::ate);

               if(attachment.good()){
                attachment.seekg (0, ifstream::end);
                size = attachment.tellg();

                if(dbgg==1){
                  cout << "Attachment size is " << size << endl;
                  logger << "Attachment size is " << size << endl;
                }                
                attachment.seekg(0,ifstream::beg);
                
                buffer = new char[size];
                attachment.read(buffer,size);
                attachment.close();
                //convert the attachment to base64 for transport
                encoded = base64_encode(reinterpret_cast<const unsigned char*>(buffer),size); 
                
                
                delete[] buffer;
                attachdata.push_back(formatString(encoded,71));//base64 requirement for string length
              }else{
                if(dbgg==1){
                  cout << "Unable to read attachment file " << attach_path.c_str() << endl;
                  logger << "Unable to read attachment file " << attach_path.c_str() << endl;
                }
              }
                  
            }