Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/mozapps/update/tests/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  test_file_hold_open.cpp

  Sprache: C
 

#include <windows.h>
#include <iostream>

// Opens a file and holds it open until the caller sends input.
// Then it closes the file and exits.

void usage(int argc, wchar_t** argv) {
  std::wcout << L"Usage:\n"
             << L"  " << argv[0] << L" filename [sharing]\n\n"
             << L"    filename\n"
             << L"      The path of the file to hold open.\n"
             << L"    sharing\n"
             << L"      File sharing flags. 'r', 'w', and/or 'd' can be\n"
             << L"      specified. Defaults to no sharing.\n\n";
}

int wmain(int argc, wchar_t** argv) {
  DWORD dwShareMode = 0;

  if (argc < 2 || argc > 3) {
    usage(argc, argv);
    exit(1);
  }
  if (argc >= 3) {
    for (wchar_t* curr = argv[2]; *curr; ++curr) {
      switch (*curr) {
        case L'w':
          dwShareMode |= FILE_SHARE_WRITE;
          break;
        case L'r':
          dwShareMode |= FILE_SHARE_READ;
          break;
        case L'd':
          dwShareMode |= FILE_SHARE_DELETE;
          break;
        default:
          usage(argc, argv);
          return 1;
      }
    }
  }
  HANDLE handle = CreateFileW(argv[1], GENERIC_READ, dwShareMode, nullptr,
                              OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
  if (handle == INVALID_HANDLE_VALUE) {
    std::wcout << L"failed to open file " << argv[1] << std::endl;
    return 1;
  }
  std::wcout << "Locked" << std::endl;
  (void)std::wcin.get();
  CloseHandle(handle);
  return 0;
}

Messung V0.5 in Prozent
C=97 H=92 G=94

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-08-24) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.