34 #include "os/memory.h" 35 #include "math_defs.h" 56 virtual Error
_open(
const String& p_path,
int p_mode_flags)=0;
57 virtual uint64_t _get_modified_time(
const String& p_file)=0;
62 static bool backup_save;
64 AccessType _access_type;
65 static CreateFunc create_func[ACCESS_MAX];
74 virtual void _set_access_type(AccessType p_access);
84 virtual void close()=0;
87 virtual void seek(
size_t p_position)=0;
88 virtual void seek_end(int64_t p_position=0)=0;
89 virtual size_t get_pos()
const=0;
90 virtual size_t get_len()
const=0;
94 virtual uint8_t
get_8()
const=0;
95 virtual uint16_t
get_16()
const;
96 virtual uint32_t
get_32()
const;
97 virtual uint64_t
get_64()
const;
99 virtual float get_float()
const;
100 virtual double get_double()
const;
101 virtual real_t get_real()
const;
103 virtual int get_buffer(uint8_t *p_dst,
int p_length)
const;
104 virtual String get_line()
const;
112 virtual void set_endian_swap(
bool p_swap) { endian_swap=p_swap; }
113 inline bool get_endian_swap()
const {
return endian_swap; }
117 virtual void store_8(uint8_t p_dest)=0;
118 virtual void store_16(uint16_t p_dest);
119 virtual void store_32(uint32_t p_dest);
120 virtual void store_64(uint64_t p_dest);
122 virtual void store_float(
float p_dest);
123 virtual void store_double(
double p_dest);
124 virtual void store_real(real_t p_real);
126 virtual void store_string(
const String& p_string);
127 virtual void store_line(
const String& p_string);
129 virtual void store_pascal_string(
const String& p_string);
130 virtual String get_pascal_string();
132 virtual void store_buffer(
const uint8_t *p_src,
int p_length);
136 virtual Error
reopen(
const String& p_path,
int p_mode_flags);
138 static FileAccess *create(AccessType p_access);
140 static FileAccess *open(
const String& p_path,
int p_mode_flags, Error *r_error=NULL);
143 static uint64_t get_modified_time(
const String& p_file);
146 static void set_backup_save(
bool p_enable) { backup_save=p_enable; };
147 static bool is_backup_save_enabled() {
return backup_save; };
155 static void make_default(AccessType p_access) {
157 create_func[p_access]=_create_builtin<T>;
173 operator bool()
const {
return f!=NULL; }
static bool exists(const String &p_name)
return true if a file exists
Definition: file_access.cpp:51
virtual uint8_t get_8() const =0
get a byte
Definition: file_access.h:166
virtual bool eof_reached() const =0
reading passed EOF
virtual size_t get_len() const =0
get size of the file
virtual uint64_t get_64() const
get 64 bits uint
Definition: file_access.cpp:216
static FileAccess * create_for_path(const String &p_path)
Create a file access (for the current platform) this is the only portable way of accessing files...
Definition: file_access.cpp:70
virtual size_t get_pos() const =0
get position in the file
virtual void store_buffer(const uint8_t *p_src, int p_length)
store an array of bytes
Definition: file_access.cpp:465
virtual uint32_t get_32() const
get 32 bits uint
Definition: file_access.cpp:197
virtual uint16_t get_16() const
get 16 bits uint
Definition: file_access.cpp:178
static CreateFunc get_create_func(AccessType p_access)
Create a file access (for the current platform) this is the only portable way of accessing files...
Definition: file_access.cpp:125
virtual Error reopen(const String &p_path, int p_mode_flags)
does not change the AccessType
Definition: file_access.cpp:90
virtual bool is_open() const =0
true when file is open
virtual void store_16(uint16_t p_dest)
store 16 bits uint
Definition: file_access.cpp:344
virtual void seek(size_t p_position)=0
seek to a given position
virtual bool file_exists(const String &p_name)=0
return true if a file exists
virtual void store_8(uint8_t p_dest)=0
store a byte
virtual void store_32(uint32_t p_dest)
store 32 bits uint
Definition: file_access.cpp:360
virtual void seek_end(int64_t p_position=0)=0
seek from the end of file
virtual Error _open(const String &p_path, int p_mode_flags)=0
open a file
virtual void store_64(uint64_t p_dest)
store 64 bits uint
Definition: file_access.cpp:377
Definition: file_access.h:40
virtual int get_buffer(uint8_t *p_dst, int p_length) const
get an array of bytes
Definition: file_access.cpp:335
virtual void close()=0
close a file
virtual Vector< String > get_csv_line(String delim=",") const
Definition: file_access.cpp:280
virtual Error get_error() const =0
get last error