Beispiel #1
0
UINT CStdioFile_i::ProcessFlags(const CString& sFilePath, UINT& nOpenFlags)
{
  m_bIsUnicodeText = false;
  
  // If we have writeUnicode we must have write or writeRead as well
#ifdef _DEBUG
  if (nOpenFlags & CStdioFile_i::modeWriteUnicode)
  {
    ASSERT(nOpenFlags & CFile::modeWrite || nOpenFlags & CFile::modeReadWrite);
  }
#endif
  
  // If reading in text mode and not creating... ; fixed by Dennis Jeryd 6/8/03
  if (nOpenFlags & CFile::typeText && !(nOpenFlags & CFile::modeCreate) && !(nOpenFlags & CFile::modeWrite ))
  {
    m_bIsUnicodeText = IsFileUnicode(sFilePath);
    
    // If it's Unicode, switch to binary mode
    if (m_bIsUnicodeText)
    {
      nOpenFlags ^= CFile::typeText;
      nOpenFlags |= CFile::typeBinary;
    }
  }
  
  m_nFlags = nOpenFlags;
  
  return nOpenFlags;
}
Beispiel #2
0
UINT CStdioFileEx::PreprocessFlags(const CString& sFilePath, UINT& nOpenFlags)
{
   m_bIsUnicodeText = false;
   
   // If we have writeUnicode we must have write or writeRead as well
   if (nOpenFlags & CStdioFileEx::modeWriteUnicode)
   {
      ASSERT(nOpenFlags & CFile::modeWrite || nOpenFlags & CFile::modeReadWrite);
      m_bIsUnicodeText = true;
   }
   // If reading in text mode and not creating...
   else if (nOpenFlags & CFile::typeText && !(nOpenFlags & CFile::modeCreate) && !(nOpenFlags & CFile::modeWrite ))
   {
      m_bIsUnicodeText = IsFileUnicode(sFilePath);
   }
   
   //如果要讀寫Unicode格式的文件,必須切換到typeBinary方式,因為這會影響fputws/fgetws的工作方式
   if (m_bIsUnicodeText)
   {
      nOpenFlags &= ~(CFile::typeText);
      nOpenFlags |= CFile::typeBinary;
   }
   
   return nOpenFlags;
}
Beispiel #3
0
UINT CStdioFileEx::ProcessFlags(const CString& sFilePath, UINT& nOpenFlags)
{
	m_bIsUnicodeText = false;

	// If reading in text mode and not creating... ; fixed by Dennis Jeryd 6/8/03
	if (nOpenFlags & CFile::typeText && !(nOpenFlags & CFile::modeCreate) && !(nOpenFlags & CFile::modeWrite ))
	{
		m_bIsUnicodeText = IsFileUnicode(sFilePath);

		// If it's Unicode, switch to binary mode
		if (m_bIsUnicodeText)
		{
			nOpenFlags ^= CFile::typeText;
			nOpenFlags |= CFile::typeBinary;
		}
	}

	m_nFlags = nOpenFlags;

	return nOpenFlags;
}
Beispiel #4
0
int __cdecl
main(
    int argc,
    BYTE *argv[])
{
    BYTE *pchFlags;
    BOOL bUnicode2;

    for (argc--, argv++; argc > 0; argc--, argv++) {
        pchFlags = argv[0];
        if ('-' == *pchFlags++) {
            while (*pchFlags != 0) {
                switch (*pchFlags++) {
                  case 'b':
                    fTruncSpace = fTrue;
                    break;

                  case 'c':
                    fCkSum = fTrue;
                    ulCkSum = 0;
                    break;

                  case 's':
                    /* SLM flag */
                    fSLM = fTrue;
                    break;

                  case 'z':
                    fCtrlZAsText = fTrue;
                    break;

                  default:
                    printf(szUsage1, rmj, rmm, rup);
                    printf(szUsage2);
                    printf(szUsage3);
                    return (retFatal);
                }
            }
        }
        else
            break;
    }

    if (!fSLM || (argc != 2)) {
        printf(szUsage1, rmj, rmm, rup);
        printf(szUsage2);
        printf(szUsage3);
        return (retFatal);
    }

    bUnicode = IsFileUnicode (argv[0]);
    bUnicode2 = IsFileUnicode (argv[1]);

    if (bUnicode != bUnicode2) {
        printf(szUsage1, rmj, rmm, rup);
        printf("ERROR - Cannot run diff between an ANSI file and an Unicode file.\n");
        return(retFatal);
    }

    /* initialize and open the files */
    InitDiff(argv[0], argv[1]);

    /* compare the two files */
    ExitDiff(FFileCompare() ? retSuccEQ : (fCkSum ? retSuccNECS : retSuccNE));
}