/* * Check whether JPilot PDB or PC3 file has changed by comparing * with cached data. * return: TRUE if file has changed. */ static gboolean jpilot_check_files( JPilotFile *pilotFile ) { gboolean retVal = TRUE; GStatBuf filestat; gchar *pcFile; /* Check main file */ if( addrcache_check_file( pilotFile->addressCache, pilotFile->path ) ) return TRUE; /* Test PC3 file */ if( ! pilotFile->havePC3 ) return FALSE; pcFile = jpilot_get_pc3_file( pilotFile ); if( pcFile == NULL ) return FALSE; if( 0 == g_lstat( pcFile, &filestat ) ) { if( filestat.st_mtime == pilotFile->pc3ModifyTime ) retVal = FALSE; } g_free( pcFile ); return retVal; }
/* ============================================================================================ */ gint vcard_read_data( VCardFile *cardFile ) { g_return_val_if_fail( cardFile != NULL, -1 ); cardFile->retVal = MGU_SUCCESS; cardFile->addressCache->accessFlag = FALSE; if( addrcache_check_file( cardFile->addressCache, cardFile->path ) ) { addrcache_clear( cardFile->addressCache ); vcard_open_file( cardFile ); if( cardFile->retVal == MGU_SUCCESS ) { /* Read data into the list */ vcard_read_file( cardFile ); vcard_close_file( cardFile ); /* Mark cache */ addrcache_mark_file( cardFile->addressCache, cardFile->path ); cardFile->addressCache->modified = FALSE; cardFile->addressCache->dataRead = TRUE; } } return cardFile->retVal; }
/* * Test whether file was modified since last access. * Return: TRUE if file was modified. */ gboolean vcard_get_modified( VCardFile *cardFile ) { g_return_val_if_fail( cardFile != NULL, FALSE ); cardFile->addressCache->modified = addrcache_check_file( cardFile->addressCache, cardFile->path ); return cardFile->addressCache->modified; }