FileIO.h 783 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // Created by miti on 21/07/19.
  3. //
  4. #ifndef DECRYPTORAPP_FILEIO_H
  5. #define DECRYPTORAPP_FILEIO_H
  6. // For reading from/writing to file -sealing.
  7. #include <fcntl.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <errno.h>
  11. #include <stdint.h> // For uint8_t* as argument.
  12. #include <unistd.h> // For lseek
  13. #include <stdio.h> // For fopen
  14. namespace FileIO {
  15. int write_to_filename(char* filename, uint8_t* msg, size_t* expected_msg_length);
  16. int read_from_filename(char* filename, uint8_t* msg, size_t* expected_msg_length);
  17. int write_to_fd(int fd, uint8_t* msg, size_t* expected_msg_length);
  18. int read_from_fd(int fd, uint8_t* msg, size_t* expected_msg_length);
  19. size_t check_if_file_exists_return_size(char* filename);
  20. };
  21. #endif //DECRYPTORAPP_FILEIO_H