Exemple #1
0
static int IsInstallationFile(LPCTSTR lpszFile)
{
	IStream* pStream = NULL;
	CaCompoundFile cmpFile(lpszFile);
	IStorage* pRoot = cmpFile.GetRootStorage();
	ASSERT(pRoot);
	if (!pRoot)
		return -1;
	DWORD grfMode = STGM_DIRECT|STGM_READ|STGM_SHARE_EXCLUSIVE;
	int nInstallation = -1;
	//
	// Load Schema Information:
	pStream = cmpFile.OpenStream(NULL, _T("SCHEMAINFO"), grfMode);
	if (pStream)
	{
		int nVersion = 0;
		CString strItem;
		COleStreamFile file (pStream);
		CArchive ar(&file, CArchive::load);

		ar >> strItem;  // Date
		ar >> nVersion; // Version
		ar >> strItem;  // Node
		ar >> strItem;  // Database
		nInstallation = strItem.IsEmpty()? 1: 0;
		ar >> strItem;  // Schema
		ar.Flush();
		pStream->Release();
	}

	return nInstallation;
}
Exemple #2
0
static void
sort(struct dirent **a, int left, int right)
{
  struct dirent *tmp, *pivot;
  int i, p;

  if (left < right) {
    pivot = a[left];
    p = left;
    for (i=left+1; i<=right; i++) {
      if (cmpFile(a[i],pivot)<0){
        p=p+1;
        tmp=a[p];
        a[p]=a[i];
        a[i]=tmp;
      }
    }
    a[left] = a[p];
    a[p] = pivot;
    sort(a, left, p-1);
    sort(a, p+1, right);
  }
}