scribble/src/FormatConverter.c File Reference

#include <gtk/gtk.h>
#include <strings.h>
#include "FileManager.h"
#include "ScribbleLog.h"
#include "ScribbleUtils.h"
#include "ink_rw.h"

Go to the source code of this file.

Functions

int fc_get_ink_dirname (char *sInkDir, int iSize, const char *sDataDir)
int fc_get_ink_filename (char *inkFileName, int iSize, const PFileManager pFM, const PScribPage pScribPage)
int fc_convertold2irx (PFileManager pFM)


Function Documentation

int fc_convertold2irx ( PFileManager  pFM  ) 

Definition at line 71 of file FormatConverter.c.

00072 {
00073     //currently, we can only(also need only) convert notes
00074     if( 0!=strcasecmp(pFM->manifest.sInkType,"notes") )
00075     {
00076         SB_ERRORPRINTF("error:unknow ink type!\n");
00077         return -1;
00078     }
00079     //load everypage and fill in Manifest
00080     PScribPage pCurrPage=pFM->manifest.pFirstScribPage;
00081     char sInkFileName[MAX_FILENAME];
00082     
00083     while(pCurrPage)
00084     {
00085         fc_get_ink_filename(sInkFileName,MAX_FILENAME,pFM,pCurrPage);
00086         pCurrPage->pink=file_read_ink(sInkFileName);
00087         if( pCurrPage->pink== NULL)
00088         {
00089             SB_FMPRINTF("-- null in page \n%s\n",pCurrPage->sPageName);
00090         }else
00091         {
00092             SB_FMPRINTF("--load strokes=%d\nin [%s]",pCurrPage->pink->nStrokes,pCurrPage->sPageName);
00093         }
00094         pCurrPage=pCurrPage->pNextPage;
00095     }
00096     SB_FMPRINTF("-- saving the old ink folder");
00097     //save the ink
00098     int iRet=fm_saveAllPages(pFM);
00099     if( 0!= iRet)
00100     {
00101         SB_FMPRINTF("-- save pages error\n");
00102         return -1;
00103     }
00104 
00105     //when success,deleted the whole ink directory.
00106     char sInkDir[MAX_PATHNAME];
00107     fc_get_ink_dirname(sInkDir,sizeof(sInkDir),pFM->sDataDir);
00108     SB_FMPRINTF("-- deleting folder [%s]", sInkDir);
00109     char* cmd = g_strdup_printf("rm -rf \"%s\"", sInkDir);
00110     system(cmd);
00111     g_free(cmd);
00112     return 0;
00113 
00114 }

Here is the call graph for this function:

int fc_get_ink_dirname ( char *  sInkDir,
int  iSize,
const char *  sDataDir 
)

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 46 of file FormatConverter.c.

00047 {
00048     SB_FMPRINTF("__start__\n");
00049     memset(sInkDir,0,iSize);
00050     snprintf (sInkDir,iSize-1, "%sink",sDataDir);
00051     SB_FMPRINTF("__end__\ninkdir=%s\n", sInkDir);
00052     return 0;
00053 }

int fc_get_ink_filename ( char *  inkFileName,
int  iSize,
const PFileManager  pFM,
const PScribPage  pScribPage 
)

Definition at line 56 of file FormatConverter.c.

00058 {
00059     //SB_FMPRINTF("__start__\n");    
00060     if( NULL==pScribPage) return -1;
00061     
00062     memset(inkFileName,0,iSize);
00063     snprintf( inkFileName,iSize-1,
00064               "%sink/%s.ink",
00065               pFM->sDataDir,
00066               pScribPage->sPageName);
00067     //SB_FMPRINTF("__end__\nresultfile=%s\n", resultFileName);
00068     return 0;
00069 }


Generated on Sun Dec 14 17:14:35 2008 by  doxygen 1.5.6