コード例 #1
0
ファイル: nsUpdateDriver.cpp プロジェクト: lofter2011/Icefox
nsresult
ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir,
               int argc, char **argv, const char *&appVersion)
{
    nsresult rv;

    nsCOMPtr<nsIFile> updatesDir;
    rv = updRootDir->Clone(getter_AddRefs(updatesDir));
    if (NS_FAILED(rv))
        return rv;
    rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("updates"));
    if (NS_FAILED(rv))
        return rv;

    rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("0"));
    if (NS_FAILED(rv))
        return rv;

    PRBool exists;
    rv = updatesDir->Exists(&exists);
    if (NS_FAILED(rv) || !exists)
        return rv;

    nsCOMPtr<nsILocalFile> statusFile;
    if (GetStatusFile(updatesDir, statusFile) && IsPending(statusFile)) {
        nsCOMPtr<nsILocalFile> versionFile;
        // Remove the update if the update application version file doesn't exist
        // or if the update's application version is less than the current
        // application version.
        if (!GetVersionFile(updatesDir, versionFile) ||
                IsOlderVersion(versionFile, appVersion)) {
            updatesDir->Remove(PR_TRUE);
        } else {
            ApplyUpdate(greDir, updatesDir, statusFile, appDir, argc, argv);
        }
    }

    return NS_OK;
}
コード例 #2
0
ファイル: nsUpdateDriver.cpp プロジェクト: isleon/Jaxer
nsresult
ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir,
               int argc, char **argv)
{
  nsresult rv;

  nsCOMPtr<nsIFile> updatesDir;
  rv = updRootDir->Clone(getter_AddRefs(updatesDir));
  if (NS_FAILED(rv))
    return rv;
  rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("updates"));
  if (NS_FAILED(rv))
    return rv;

  PRBool exists;
  rv = updatesDir->Exists(&exists);
  if (NS_FAILED(rv) || !exists)
    return rv;

  nsCOMArray<nsIFile> dirEntries;
  rv = ScanDir(updatesDir, &dirEntries);
  if (NS_FAILED(rv))
    return rv;
  if (dirEntries.Count() == 0)
    return NS_OK;

  // look for the first update subdirectory with a status of pending
  for (int i = 0; i < dirEntries.Count(); ++i) {
    nsCOMPtr<nsILocalFile> statusFile;
    if (GetStatusFile(dirEntries[i], statusFile) && IsPending(statusFile)) {
      ApplyUpdate(greDir, dirEntries[i], statusFile, appDir, argc, argv);
      break;
    }
  }

  return NS_OK;
}