file_access_encrypted.h
1 #ifndef FILE_ACCESS_ENCRYPTED_H
2 #define FILE_ACCESS_ENCRYPTED_H
3 
4 
5 #include "os/file_access.h"
6 
8 public:
9 
10  enum Mode {
11  MODE_READ,
12  MODE_WRITE_AES256,
13  MODE_MAX
14  };
15 
16 private:
17 
18 
19  Mode mode;
20  Vector<uint8_t> key;
21  bool writing;
22  FileAccess *file;
23  size_t base;
24  size_t length;
25  Vector<uint8_t> data;
26  mutable size_t pos;
27  mutable bool eofed;
28 
29 
30 public:
31 
32 
33 
34 
35  Error open_and_parse(FileAccess *p_base,const Vector<uint8_t>& p_key,Mode p_mode);
36  Error open_and_parse_password(FileAccess *p_base,const String& p_key,Mode p_mode);
37 
38  virtual Error _open(const String& p_path, int p_mode_flags);
39  virtual void close();
40  virtual bool is_open() const;
41 
42  virtual void seek(size_t p_position);
43  virtual void seek_end(int64_t p_position=0);
44  virtual size_t get_pos() const;
45  virtual size_t get_len() const;
46 
47  virtual bool eof_reached() const;
48 
49  virtual uint8_t get_8() const;
50  virtual int get_buffer(uint8_t *p_dst, int p_length) const;
51 
52  virtual Error get_error() const;
53 
54  virtual void store_8(uint8_t p_dest);
55  virtual void store_buffer(const uint8_t *p_src,int p_length);
56 
57  virtual bool file_exists(const String& p_name);
58 
59  virtual uint64_t _get_modified_time(const String& p_file);
60 
63 };
64 
65 #endif // FILE_ACCESS_ENCRYPTED_H
virtual Error get_error() const
get last error
Definition: file_access_encrypted.cpp:226
virtual void seek_end(int64_t p_position=0)
seek from the end of file
Definition: file_access_encrypted.cpp:177
virtual uint8_t get_8() const
get a byte
Definition: file_access_encrypted.cpp:195
virtual bool eof_reached() const
reading passed EOF
Definition: file_access_encrypted.cpp:190
virtual void seek(size_t p_position)
seek to a given position
Definition: file_access_encrypted.cpp:166
virtual bool is_open() const
true when file is open
Definition: file_access_encrypted.cpp:161
virtual int get_buffer(uint8_t *p_dst, int p_length) const
get an array of bytes
Definition: file_access_encrypted.cpp:208
virtual size_t get_len() const
get size of the file
Definition: file_access_encrypted.cpp:185
virtual bool file_exists(const String &p_name)
return true if a file exists
Definition: file_access_encrypted.cpp:266
virtual void store_8(uint8_t p_dest)
store a byte
Definition: file_access_encrypted.cpp:253
virtual Error _open(const String &p_path, int p_mode_flags)
open a file
Definition: file_access_encrypted.cpp:98
virtual size_t get_pos() const
get position in the file
Definition: file_access_encrypted.cpp:181
Definition: ustring.h:64
Definition: file_access_encrypted.h:7
Definition: file_access.h:40
virtual void close()
close a file
Definition: file_access_encrypted.cpp:102
virtual void store_buffer(const uint8_t *p_src, int p_length)
store an array of bytes
Definition: file_access_encrypted.cpp:231