30 class CLASS_DECL_ACME
file :
31 virtual public property_object,
32 virtual public streamable
37 ::file::e_open m_eopen;
39 ::file::e_state m_estate;
40 class ::time m_timeErrorBlockTimeout;
44 explicit file(const ::file::path &
path);
52 virtual ::i32_boolean is_end_of_file()
const;
53 virtual void set_end_of_file();
55 inline bool _is_end_of_file()
const {
return is_end_of_file(); }
57 virtual bool is_in_memory_file()
const;
59 virtual ::u8 * full_data_begin();
61 virtual ::u8 * full_data_end();
63 virtual const ::u8 * full_data_begin()
const;
65 virtual const ::u8 * full_data_end()
const;
68 inline ::block full_data(memsize start = 0, memsize count = -1)
71 return ::block(full_data_begin(), full_data_end())(start, count);
76 inline ::block full_data(memsize start = 0, memsize count = -1)
const
79 return ::block(full_data_begin(), full_data_end())(start, count);
84 inline memsize full_data_size()
const {
return full_data_end() - full_data_begin(); }
86 inline bool full_data_is_set()
const { return ::is_set(full_data_begin()); }
89 virtual ::u8 * data_begin();
91 virtual ::u8 * data_end();
93 virtual const ::u8 * data_begin()
const;
95 virtual const ::u8 * data_end()
const;
98 inline ::block data(memsize start = 0, memsize count = -1)
101 return ::block(data_begin(), data_end())(start, count);
106 inline ::block data(memsize start = 0, memsize count = -1)
const
109 return ::block(data_begin(), data_end())(start, count);
113 inline memsize data_size()
const {
return data_end() - data_begin(); }
115 inline bool data_is_set()
const { return ::is_set(data_begin()) && data_size() > 0; }
133 void translate(filesize offset, ::enum_seek eseek)
override;
134 virtual ::i32 getc();
135 virtual ::i32 ungetc(::i32 iChar);
137 inline filesize get_remaining_byte_count()
const {
return size() - get_position(); }
141 using ::file::readable::read;
142 memsize read(
void * p, ::memsize s)
override;
145 virtual filesize find(
const void* pFind, memsize size,
const filesize* limit);
147 ::filesize right_size()
const override;
150 virtual ::memory as_memory();
153 template <
typename TYPE >
154 void write_as_block(
const TYPE & t) { write({ e_as_block, t }); }
157 using ::file::writable::write;
158 void write(
const void * p, memsize s)
override;
160 virtual void write_unsigned_char(::u8 uch);
163 memsize
defer_write(
const void * dataToWrite, memsize amountToWrite)
override;
166 virtual void write(::file::readable * preader, memsize uiBufferSize = 16_MiB);
167 virtual void write_from_beginning(::file::streamable * preader, memsize uiBufSize = 16_MiB);
184 void abort()
override;
185 void flush()
override;
186 void close()
override;
189 virtual file & put(::i8 ch);
191 virtual file & getline(char_pointer sz, character_count n);
194 virtual bool read(char_pointer pch);
195 virtual bool read(::u8 * puch);
196 virtual bool peek(char_pointer pch);
197 virtual bool peek(::u8 * puch);
201 virtual ::i32 peek_byte();
202 virtual void put_byte_back(::u8 b);
204 virtual ::i32 get_unsigned_char();
205 inline ::u8 get_byte_unbounded() {
return get_unsigned_char(); }
207 virtual ::i32 get_unsigned_short();
208 inline ::u16 get_u16_unbounded() {
return get_unsigned_short(); }
210 virtual bool get_u64(::u64 & hn);
211 inline ::u64 get_u64_unbounded() { ::u64 ull; get_u64(ull);
return ull; }
214 virtual bool unget_if(::ansi_character ch);
216 inline filesize _right_size() {
return this->right_size(); }
219 virtual bool read_string(
string & str);
228 virtual void print(const ::scoped_string & scopedstr);
229 virtual void println(const ::scoped_string & scopedstr);
230 virtual void printf(const_char_pointer format, ...);
235 virtual void write_from_hex(const ::block &
block);
237 virtual void set_storing();
238 virtual void set_loading();
243 virtual ::file::path get_file_path()
const;
244 virtual void set_file_path(const ::file::path &
path);
247 virtual void open(const ::file::path &
path, ::file::e_open eopen, ::pointer < ::file::exception > * pfileexception =
nullptr);
250 inline void open_for_reading(const ::file::path&
path, ::file::e_open eopen =
251 ::file::e_open_binary, ::pointer < ::file::exception > * pfileexception =
nullptr)
254 open(
path, eopen | ::file::e_open_read);
259 virtual void open_for_writing(const ::file::path&
path, ::file::e_open eopen =
260 ::file::e_open_binary | ::file::e_open_defer_create_directory, ::pointer < ::file::exception > * pfileexception =
nullptr)
263 open(
path, eopen | ::file::e_open_write);
268 ::file::fmtflags flags()
const;
270 ::file::fmtflags flags(::file::fmtflags flags);
274 void set_size(filesize dwNewLen)
override;
275 filesize size()
const override;
276 inline bool is_empty()
const {
return size() <= 0; }
277 inline bool has_data()
const {
return size() > 0; }
278 inline void clear() { set_size(0); }
280 virtual void lock(filesize dwPos, filesize dwCount);
281 virtual void unlock(filesize dwPos, filesize dwCount);
284 virtual string get_location()
const;
287 virtual bool is_valid()
const;
288 virtual bool is_opened()
const;
291 virtual void put_lines(
const string_array_base& stra);
293 virtual class ::time modification_time();
294 virtual void set_modification_time(
const class ::time &
time);