![]() Record->SeqNumber = Master ? 0 : SeqNumber ĭATA_RECORD* PrepareRecord(ULONG SeqNumber) Either zero, if there are no free records, or the position of the record This function iterates through the bitmap and reserves the first free record ULONG ReserveFirstFreeRecord(BYTE* Bitmap) = Exclusive īOOL UnlockRecord(HANDLE hFile, ULONG RecNumber) Return IoRecord(hFile, RecNumber, &IoParam) īOOL WriteRecord(HANDLE hFile, ULONG RecNumber, PVOID Record, ULONG RecSize)īOOL LockRecord(HANDLE hFile, ULONG RecNumber, BOOL Exclusive) parameters in the IO_PARAM block to correspond to the requested operation andīOOL ReadRecord(HANDLE hFile, ULONG RecNumber, PVOID Record, ULONG RecSize) The following functions are wrappers around IoRecord, they just set the correct MSG_PRINTF(L"IoRecord failed with error 0x%08x. MSG_PRINTF(L"GetOverlappedResult for Overlapped.hEvent failed with error 0x%08x.\n", PIoParam-> ? LOCKFILE_EXCLUSIVE_LOCK : 0, Overlapped.OffsetHigh = RecOffset.HighPart RecOffset.QuadPart = RecNumber * RECORD_SIZE ![]() MSG_PRINTF(L"CreateEvent for Overlapped.hEvent failed with error 0x%08x.\n", SecureZeroMemory(&Overlapped, sizeof(OVERLAPPED)) TRUE if the I/O succeeded, FALSE if not. ![]() pIoParam - Pointer to IO_PARAM structure. RecNumber - Number of the record to be operated on. hFile - Handle to the file containing the records. to the parameters passed in the IO_PARAM block. This function performs I/O (read, write, lock or unlock) in a record, according MSG_PRINTF(L"An error has been logged, calling ExitThread.\n") īOOL IoRecord(HANDLE hFile, ULONG RecNumber, PIO_PARAM pIoParam) This function is called immediately after an unrecoverable error is logged. Parameter block for I/Os passed to IoRecord. Types of operations for OperateOnRecord. ULONG SeqNumber // Starts at 1 and is incremented every time contents are modified.īYTE Bitmap // A bitmap indicating which records are allocated.īYTE Data // Record raw data. ULONG TypeCode // Either MASTER_RECORD_TYPE_CODE or DATA_RECORD_TYPE_CODE. #define DATA_SIZE ((RECORD_SIZE) - sizeof(RECORD_HEADER)) Printf("CreateFile failed (%d)\n", GetLastError()) HANDLE hFile = CreateFile(TEXT("datafile.txt"), Create the file, open for both read and write. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF Nota En este ejemplo no se cambian los datos después de bloquear el archivo. El primer ejemplo es una demostración sencilla para crear un archivo, escribir algunos datos en él y, a continuación, bloquear una sección en el medio. Para obtener un ejemplo de uso de LockFile, vea Anexar un archivo a otro archivo.Įn los ejemplos siguientes se muestra cómo usar LockFileEx. Una aplicación desbloquea el intervalo de bytes mediante la función UnlockFile o UnlockFileEx y debe desbloquear todas las áreas bloqueadas antes de cerrar un archivo. Esto se puede usar para crear un intervalo de bytes de solo lectura en un archivo. Un bloqueo compartido deniega a todos los procesos acceso de escritura al intervalo de bytes especificado de un archivo, incluido el proceso que bloquea primero el intervalo de bytes. Un bloqueo exclusivo deniega a todos los demás procesos acceso de lectura y escritura al intervalo de bytes especificado de un archivo. La función LockFileEx permite a una aplicación especificar uno de los dos tipos de bloqueos. Los bloqueos de intervalo de bytes se omiten al usar archivos asignados a memoria.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |