Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. HP_ErrorCode HP_CreateFile(const char *filename) {
  2. //insert code here
  3. //stages : CREATE , OPEN , INIT , ALLOCATE , SET DIRTY , UNPIN , CLOSE
  4. int fd;
  5. printf("call open file\n");
  6. CALL_BF(BF_CreateFile(filename));
  7. CALL_BF(BF_OpenFile(filename , &fd));
  8. printf("call open file end \n");
  9.  
  10. printf("lets create a block\n");
  11. BF_Block *block ; //Ορίζω ένα block.
  12.  
  13. printf("lets init block\n");
  14. BF_Block_Init(&block);
  15. printf("block initialized\n");
  16. printf("lets allocate memory\n");
  17. CALL_BF(BF_AllocateBlock(fd,block)); //δημιουργώ χώρο στο μπλοκ
  18. printf("memory allocated\n");
  19.  
  20. printf("lets get data\n");
  21. char* d = BF_Block_GetData(block);
  22. printf("bf get data end\n");
  23. //memset (d , 'h', sizeof('h'));
  24. * d='h' ;
  25. printf("this is a %seap file\n" ,d);
  26.  
  27. printf("lets set the block dirty\n");
  28. BF_Block_SetDirty(block);
  29. printf("block setdirty end\n");
  30.  
  31. printf("lets unpin the block\n");
  32. CALL_BF(BF_UnpinBlock(block));
  33. printf("block unpin end\n");
  34.  
  35. printf("lets close file\n");
  36. CALL_BF(BF_CloseFile(fd));
  37. printf("close file end\n");
  38. return HP_OK;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement