Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.1 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. ccreate.c
  5. Abstract:
  6. This module contains the code to create a
  7. new cab file.
  8. Author:
  9. Wesley Witt (wesw) 29-Sept-1998
  10. Revision History:
  11. --*/
  12. #include <ntcabp.h>
  13. #pragma hdrstop
  14. BOOL
  15. NtCabCreateNewCabFile(
  16. IN PCAB_INSTANCE_DATA CabInst,
  17. IN PCWSTR CabFileName
  18. )
  19. {
  20. NTSTATUS Status;
  21. HANDLE hCab;
  22. DWORD Bytes;
  23. CAB_HEADER CabHeader;
  24. CabInst->NewCabFile = TRUE;
  25. CabInst->hCab = CreateFile(
  26. CabFileName,
  27. GENERIC_WRITE | GENERIC_READ,
  28. 0,
  29. NULL,
  30. CREATE_ALWAYS,
  31. FILE_ATTRIBUTE_NORMAL,
  32. NULL
  33. );
  34. if (CabInst->hCab == INVALID_HANDLE_VALUE) {
  35. return FALSE;
  36. }
  37. CabHeader.Signature = NTCAB_SIGNATURE;
  38. CabHeader.Version = NTCAB_VERSION;
  39. CabHeader.DirOffset = 0;
  40. Status = WriteFile(
  41. CabInst->hCab,
  42. &CabHeader,
  43. sizeof(CAB_HEADER),
  44. &Bytes,
  45. NULL
  46. );
  47. InitializeListHead( &CabInst->CabDir );
  48. CabInst->CabFileName = _wcsdup( CabFileName );
  49. return TRUE;
  50. }