Err vfsImportDatabaseFromFile(UInt16 volRefNum, Char *pathNameP, UInt16 *cardNoP, LocalID *dbIDP) { axxPacFD fd; Err ret; Boolean needReset; Char nameP[32]; if ((fd = axxPacOpen(LibRef, pathNameP, O_RdOnly)) < 0) return vfsErrBadName; *cardNoP = 0; ret = ExgDBRead(&ReadDataFromFile,DeleteProc, &fd, dbIDP, *cardNoP, &needReset, true); ret = axxPacClose(LibRef, fd); if (ret < 0) return expErrNotEnoughPower; if (ret == dmErrAlreadyExists) { ret = vfsFileDBInfo(fd, nameP, NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL); *dbIDP = DmFindDatabase(0, nameP); *cardNoP = 0; } return ret; }
/*********************************************************************** * * FUNCTION: ReceiveDatabase * * DESCRIPTION: Receives data in the input field using the Exg API * * RETURNED: error code or zero for no error. * ***************************************************************************/ static Err ReceiveDatabase (ExgSocketPtr exgSocketP) { Err err; LocalID dbID; UInt16 cardNo = 0; Boolean *needResetP = NULL; Boolean keepDates = false; char outName [32]; char appName [32]; int bytesSent = -1; LocalID app_dbID; // Create exgSocket structure MemSet(exgSocketP, sizeof(exgSocketP->length), 0); // Start and exchange put operation err = ExgAccept(exgSocketP); if (!err){ // Receive the DB name we fix it at 32 bytes bytesSent = ExgReceive(exgSocketP, outName, 32, &err); if(bytesSent != 32){ return err; } // Receive the DB name we fix it at 32 bytes bytesSent = ExgReceive(exgSocketP, appName, 32, &err); if(bytesSent != 32){ return err; } // Receive the database err = ExgDBRead(ReadDBData, DeleteExistingDB, exgSocketP, &dbID, cardNo, needResetP, keepDates); /* exgSocketP->goToCreator = 'CCPr'; exgSocketP->noGoTo = 0; */ // Disconnect Exg and pass error err = ExgDisconnect(exgSocketP, err); // Try to rename the database to the outName if(StrLen(outName) > 0){ /* UInt cardNo, LocalID dbID, CharPtr nameP, UIntPtr attributesP, UIntPtr versionP, ULongPtr crDateP, ULongPtr modDateP, ULongPtr bckUpDateP, ULongPtr modNumP, LocalID* appInfoIDP, LocalID* sortInfoIDP, ULongPtr typeP, ULongPtr creatorP); */ DmSetDatabaseInfo(cardNo, dbID, outName, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } if (!err && StrLen(appName) > 0) { // Find the database app_dbID = DmFindDatabase(0, appName); if(app_dbID != 0) { SysUIAppSwitch(0, app_dbID, sysAppLaunchCmdNormalLaunch, NULL); } } } /****************************************************************************/ return err; }