JpegStreamSaver.cpp
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <sys/stat.h>
00003 #include <sys/types.h>
00004 #include <unistd.h>
00005 
00006 #include "canon_vbc50i/libCanon/JpegStreamSaver.h"
00007 
00008 bool JpegStreamSaver::record(const char * buffer, unsigned int size)
00009 {
00010         char cstr[16],dstr[16];
00011         FILE * fp;
00012         std::string s;
00013         while (1) {
00014                 sprintf(dstr,"-%08d",counter/1000);
00015                 sprintf(cstr,"/%03d.jpg",counter%1000);
00016                 s = directory+ "/" + base + dstr;
00017                 mkdir(s.c_str(),0775);
00018                 s += cstr;
00019                 fp = fopen(s.c_str(),"r");
00020                 if (fp == NULL) break;
00021                 fprintf(stderr,"Warning: skipping '%s'\n",s.c_str());
00022                 fclose(fp);
00023                 counter += 1;
00024                 if (counter == 0) /* loop */ {
00025                         counter -= 1;
00026                         return false;
00027                 }
00028         }
00029         fp = fopen(s.c_str(),"w");
00030         unsigned int rs = fwrite(buffer,size,1,fp);
00031         fclose(fp);
00032         counter += 1;
00033         return (rs == 1);
00034 }
00035 


canon_vbc50i
Author(s): Cedric Pradalier
autogenerated on Sun Oct 5 2014 23:47:45