/* %%Function:CommAllELOF %%Owner:bradch */ CommAllELOF() { struct ELOF ** hELOF; int stm; CommSzNum("Displaying all ELOF's, 1 through ", stmLast); for (stm = stmMin; stm < stmMax; stm++) { CommSzNum(" ELOF number ", stm); hELOF = mpstmM1hELOF[stm - 1]; if (hELOF == hNil) { CommSz(" hELOF is hNil.\r\n"); } else { CommSzNum(" hFile=", (*hELOF)->hFile); CommSzNum(" ofs.fFixedDisk=", (unsigned) (*hELOF)->ofs.fFixedDisk); CommSzNum(" ofs.nErrCode=", (*hELOF)->ofs.nErrCode); CommSzSz(" ofs.szFile=", (*hELOF)->ofs.szFile); switch ((*hELOF)->wMode) { case OF_READ: CommSz(" wMode=OF_READ\r\n"); break; case OF_WRITE: CommSz(" wMode=OF_WRITE\r\n"); break; default: CommSz(" wMode=unknown...\r\n"); break; } CommSzLong(" lcch=", (*hELOF)->lcch); } } }
DoFileSaveAs(void) { /* This routine handles input to the Save dialog box. */ static CHAR szDefault[ cchMaxFile ]; extern int vfTextOnlySave; extern DoSaveAsFilenameGet(LPSTR,LPSTR,int *,int *,int * ,int *); BOOL bDontDelPictures=FALSE; int fWordFmt, fTextOnly, fBackup, fOldWrite; CHAR szFullNameNewDoc[ cchMaxFile ]; // full name of selection CHAR szShortNameNewDoc[ cchMaxFile ]; // file name of selection CHAR szDocName[ cchMaxFile ]; // file name of current #define szFullNameCurDoc (**((**hpdocdod)[docCur].hszFile)) // full name of current #define pDod ((struct DOD *)&(**hpdocdod)[docCur]) { int cch = 0; CHAR szDOSPath[ cchMaxFile ]; if (FNormSzFile( szDOSPath, "", dtyNormal )) { if ((cch=CchSz( szDOSPath )-2) > 2) { Assert( szDOSPath[ cch ] == '\\'); szDOSPath [cch] = '\0'; } #if 0 if (cch > 3) szDOSPath [cch] = '\\'; #endif } else szDOSPath[0] = '\0'; if (szFullNameCurDoc [0] != '\0') { /* Set default string for filename edit area */ CHAR szDocPath[ cchMaxFile ]; // path to current FreezeHp(); SplitSzFilename( szFullNameCurDoc, szDocPath, szDocName ); /* Default filename does not include the document's path if it is == the current directory path */ if (WCompSz( szDOSPath, szDocPath ) == 0) bltsz(szDocName, szDefault); else bltsz(szFullNameCurDoc, szDefault); MeltHp(); } else { szDefault[0] = szDocName[0] = '\0'; } } fTextOnly = vfTextOnlySave; fBackup = vfBackupSave; fWordFmt = vWordFmtMode & ~CONVFROMWORD; fOldWrite = vfOldWriteFmt; EnableOtherModeless(FALSE); while(1) { if (!DoSaveAsFilenameGet(szDefault,szFullNameNewDoc,&fBackup,&fTextOnly,&fWordFmt,&fOldWrite)) goto end; else { int dty; if (szFullNameNewDoc[0] == '\0') goto end; if (fOldWrite || fWordFmt || fTextOnly) { if (!WannaDeletePictures(docCur,fOldWrite ? SF_OLDWRITE : SF_WORD)) continue; } StartLongOp(); szFileExtract(szFullNameNewDoc, szShortNameNewDoc); #ifdef INTL /* International version */ /* Read the "Microsoft Word Format" button */ /* vWordFmtMode is used in WriteFn. If true, will convert to Word format, if false, no conversion is done. Another value, CONVFROMWORD, can be given during an open to allow saving a Word document in Write format. */ if (fWordFmt) /* if set, make the default extension be doc instead of wri for word docs */ dty = dtyWordDoc; else #endif /* International version */ dty = dtyNormal; #if WINVER >= 0x300 /* Currently: FNormSzFile *TAKES* an OEM sz, and *RETURNS* an ANSI sz ..pault */ #endif if ( pDod->fReadOnly && WCompSz( szFullNameNewDoc, szFullNameCurDoc ) == 0) { /* Must save read-only file under a different name */ Error( IDPMTReadOnly ); goto NSerious; /* Error not serious, stay in dialog */ } #if WINVER >= 0x300 else if (WCompSz(szFullNameCurDoc, szFullNameNewDoc) == 0 && vWordFmtMode == CONVFROMWORD && vfTextOnlySave == fTextOnly) /* User has loaded a text file and is going to save under the same name without changing formats, *OR* has loaded a Word document and is going to save in the same format -- don't prompt "replace file?" ..pault 1/17/90 */ ; #endif else if ((WCompSz(szFullNameCurDoc, szFullNameNewDoc) != 0 #ifdef INTL /* International version */ /* vWordFmtMode hasn't be reset yet */ || ( vWordFmtMode == CONVFROMWORD) #endif /* International version */ ) && FExistsSzFile( dtyNormal, szFullNameNewDoc ) ) { /* User changed the default string and specified a filename for which the file already exists. Or, we did a Word format conversion, forcing the .WRI extension on the file, and a file with that name exists.(International version only).o Note that vfWordFmtMode will be set to True or False below, so this check is made only on the first save after a Word conversion. Prompt to make sure it's ok to trash the existing one */ CHAR szFileUp[ cchMaxFile ]; CHAR szUserOEM[cchMaxFile]; /* ..converted to OEM */ CHAR szT[ cchMaxSz ]; CchCopyUpperSz( szShortNameNewDoc, szFileUp ); MergeStrings (IDSTRReplaceFile, szFileUp, szT); #if WINVER >= 0x300 /* access() expects OEM! */ AnsiToOem((LPSTR) szFullNameNewDoc, (LPSTR) szUserOEM); /* Make sure we don't let someone try to save to a file to which we do not have r/w permission */ Diag(CommSzNum("fnSaveAs: access(write_perm)==", access(szUserOEM, WRITE_PERMISSION))); Diag(CommSzNum(" szExists()==", FExistsSzFile( dtyNormal, szFullNameNewDoc ))); if (access(szUserOEM, WRITE_PERMISSION) == -1) { /* THIS COULD BE A CASE OF WRITING TO A FILE WITH R/O ATTRIBUTE, *OR* A SHARING ERROR! IMPROVE ERROR MESSAGE HERE ..pault 11/2/89 */ //Error( IDPMTSDE2 ); Error( IDPMTReadOnly ); goto NSerious; /* Error not serious, stay in dialog */ } #endif } vfTextOnlySave = fTextOnly; vfBackupSave = fBackup; vfOldWriteFmt = fOldWrite; #ifdef INTL /* International version */ /* vWordFmtMode is used in WriteFn. If true, will convert to Word format, if false, no conversion is done. Another value, CONVFROMWORD, can be given during an open to allow saving a Word document in Write format. */ vWordFmtMode = fWordFmt; #endif /* International version */ /* Record whether a backup was made or not. */ WriteProfileString( (LPSTR)szWriteProduct, (LPSTR)szBackup, vfBackupSave ? (LPSTR)"1" : (LPSTR)"0" ); /* Save the document */ CmdXfSave( szFullNameNewDoc,!vfTextOnlySave, vfBackupSave, vhcArrow); if (vfDiskFull || vfSysFull) goto NSerious; /* Case 1: Serious error. Leave the dialog. */ if (vfDiskError) { EndLongOp( vhcArrow ); goto end; } /* Case 2: Saved OK: set the new title, leave the dialog. */ else if (!WCompSz( szFullNameNewDoc, szFullNameCurDoc )) { #if defined(OLE) ObjRenamedDoc(szFullNameNewDoc); ObjSavedDoc(); #endif SetTitle(szShortNameNewDoc); #if WINVER >= 0x300 FreeUnreferencedFns(); #endif /* Update the fReadOnly attribute (9.10.91) v-dougk */ pDod->fReadOnly = FALSE; // can't be readonly if just saved EndLongOp( vhcArrow ); goto end; } /* Case 3: Nonserious error (disk full, bad path, etc.). stay in dialog. */ else { NSerious: ferror = FALSE; EndLongOp( vhcArrow ); StayInDialog: CloseEveryRfn( TRUE ); } } } // end of while(1) end: EnableOtherModeless(FALSE); } /* end of DoFileSaveAs */