diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-11-11 00:00:24 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-11-11 00:00:24 +0000 |
commit | 663f58eb03ce8bcaa21e751077144faaaf202b32 (patch) | |
tree | 3fe34d8e9a9390922015142891fd6b4e79b865c4 /recordmydesktop/src/rmd_cache.c | |
parent | b89af75ae20823839a343b1d877fba7d9d76b640 (diff) |
Cache files are now broken on 500mb parts, measured always as uncomressed bytes
as gzwrite returns them, in order to avoid gzlib 2 gb file size limit.
CacheFileN,SwapCacheFilesWrite,SwapCacheFilesRead functions have been added to
achieve this without messing with normal operation(i.e. the rest of the program
keeps operating on the same file pointer). Also PurgeCache function has been added
to separate the task from encoding itself.
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@160 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src/rmd_cache.c')
-rw-r--r-- | recordmydesktop/src/rmd_cache.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/recordmydesktop/src/rmd_cache.c b/recordmydesktop/src/rmd_cache.c index ca13095..2a49895 100644 --- a/recordmydesktop/src/rmd_cache.c +++ b/recordmydesktop/src/rmd_cache.c @@ -26,6 +26,78 @@ #include <recordmydesktop.h> + +void CacheFileN(char *name,char **newname,int n){//nth cache file + char numbuf[8]; + strcpy(*newname,name); + strcat(*newname,"."); + I16TOA((n),numbuf) + strcat(*newname,numbuf); +} + +int SwapCacheFilesWrite(char *name,int n,gzFile **fp,FILE **ucfp){ + char *newname=malloc(strlen(name)+10); + CacheFileN(name,&newname,n); + if(*fp==NULL){ + fflush(*ucfp); + fclose(*ucfp); + *ucfp=fopen(newname,"wb"); + } + else{ + gzflush(*fp,Z_FINISH); + gzclose(*fp); + *fp=gzopen(newname,"wb0f"); + } + free(newname); + return ((*fp==NULL)&&(*ucfp==NULL)); +} + +int SwapCacheFilesRead(char *name,int n,gzFile **fp,FILE **ucfp){ + char *newname=malloc(strlen(name)+10); + CacheFileN(name,&newname,n); + if(*fp==NULL){ + fclose(*ucfp); + *ucfp=fopen(newname,"rb"); + } + else{ + + gzclose(*fp); + *fp=gzopen(newname,"rb"); + } + free(newname); + return ((*fp==NULL)&&(*ucfp==NULL)); +} + +int PurgeCache(CacheData *cache_data_t,int sound){ + struct stat buff; + char *fname; + fname=malloc(strlen(cache_data_t->imgdata)+10); + strcpy(fname,cache_data_t->imgdata); + int exit_value=0; + int nth_cache=1; + + while (stat(fname,&buff)==0){ + if(remove(fname)){ + fprintf(stderr,"Couldn't remove temporary file %s",cache_data_t->imgdata); + exit_value=1; + } + CacheFileN(cache_data_t->imgdata,&fname,nth_cache); + nth_cache++; + } + free(fname); + if(sound){ + if(remove(cache_data_t->audiodata)){ + fprintf(stderr,"Couldn't remove temporary file %s",cache_data_t->audiodata); + exit_value=1; + } + } + if(remove(cache_data_t->projname)){ + fprintf(stderr,"Couldn't remove temporary directory %s",cache_data_t->projname); + exit_value=1; + } + return exit_value; +} + void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t){ int width,height,offset_x,offset_y,pid; char pidbuf[8]; |