|
static const std::string & | s_class () |
|
|
static bool | access_path (const std::string &a_path, EAccessMode a_mode) |
|
static bool | unlink (const std::string &a_path) |
|
static int | _open (const char *a_name, int a_flags, unsigned int a_mode) |
|
static bool | zip (std::ostream &a_out, compress_func a_func, int a_level, uint32 a_srcsize, char *a_src, uint32 a_tgtsize, char *a_tgt, uint32 &a_irep) |
|
Definition at line 34 of file file.
◆ EAccessMode
Enumerator |
---|
kFileExists | |
kExecutePermission | |
kWritePermission | |
kReadPermission | |
Definition at line 458 of file file.
◆ file() [1/2]
tools::wroot::file::file |
( |
std::ostream & |
a_out, |
|
|
const std::string & |
a_path, |
|
|
bool |
a_verbose = false |
|
) |
| |
|
inline |
Definition at line 221 of file file.
241 mem::increment(
s_class().c_str());
249 m_out <<
"tools::wroot::file::file :"
250 <<
" " << sout(
m_path) <<
" root directory badly created."
257 O_RDWR | O_CREAT | O_BINARY,S_IREAD | S_IWRITE
259 O_RDWR | O_CREAT,0644
263 m_out <<
"tools::wroot::file::file :"
264 <<
" can't open " << sout(a_path) <<
"."
290 m_out <<
"tools::wroot::file::file :"
291 <<
" can't write file header."
296 {
char* pos = key.data_buffer();
298 if(!wb.write(
m_path))
return;
303 m_out <<
"tools::wroot::file::file :"
319 if(!key.write_self(*
this)) {
320 m_out <<
"tools::wroot::file::file :"
321 <<
" key.write_self() failed."
329 if(!key.write_file(*
this,n)) {
330 m_out <<
"tools::wroot::file::file :"
331 <<
" can't write key in file."
◆ ~file()
virtual tools::wroot::file::~file |
( |
| ) |
|
|
inlinevirtual |
Definition at line 338 of file file.
341 mem::decrement(
s_class().c_str());
◆ file() [2/2]
tools::wroot::file::file |
( |
const file & |
a_from | ) |
|
|
inlineprotected |
Definition at line 345 of file file.
351 mem::increment(
s_class().c_str());
◆ _open()
static int tools::wroot::file::_open |
( |
const char * |
a_name, |
|
|
int |
a_flags, |
|
|
unsigned int |
a_mode |
|
) |
| |
|
inlinestaticprotected |
Definition at line 491 of file file.
492 #if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
493 return ::open64(a_name,a_flags,a_mode);
495 return ::open(a_name,a_flags,a_mode);
◆ access_path()
static bool tools::wroot::file::access_path |
( |
const std::string & |
a_path, |
|
|
EAccessMode |
a_mode |
|
) |
| |
|
inlinestaticprotected |
Definition at line 464 of file file.
468 return (::_access(a_path.c_str(),a_mode) == 0) ? true :
false;
470 return (::access(a_path.c_str(),a_mode) == 0) ? true :
false;
◆ add_ziper()
bool tools::wroot::file::add_ziper |
( |
char |
a_key, |
|
|
compress_func |
a_func |
|
) |
| |
|
inline |
Definition at line 447 of file file.
448 std::map<char,compress_func>::const_iterator it =
m_zipers.find(a_key);
◆ byte_swap()
virtual bool tools::wroot::file::byte_swap |
( |
| ) |
const |
|
inlinevirtual |
◆ close()
void tools::wroot::file::close |
( |
| ) |
|
|
inline |
Definition at line 369 of file file.
370 if(
m_file==not_open())
return;
375 m_out <<
"tools::wroot::file::close :"
376 <<
" can't write free segments."
380 m_out <<
"tools::wroot::file::close :"
381 <<
" can't write file header."
386 {std::list<free_seg*>::iterator it;
◆ compress_buffer()
virtual void tools::wroot::file::compress_buffer |
( |
const buffer & |
a_buffer, |
|
|
char *& |
a_kbuf, |
|
|
uint32 & |
a_klen, |
|
|
bool & |
a_kdel |
|
) |
| |
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 169 of file file.
176 uint32 nbytes = a_buffer.length();
178 if(cxlevel && (nbytes>256)) {
180 if(!
ziper(
'Z',func)) {
184 a_kbuf = (
char*)a_buffer.buf();
185 a_klen = a_buffer.length();
188 const uint32 kMAXBUF = 0xffffff;
190 uint32 nbuffers = nbytes/kMAXBUF;
191 uint32 buflen = nbytes+HDRSIZE*(nbuffers+1);
192 a_kbuf =
new char[buflen];
194 char* src = (
char*)a_buffer.buf();
197 for(
uint32 i=0;i<=nbuffers;i++) {
198 uint32 bufmax = ((i == nbuffers) ? nbytes - nzip : kMAXBUF);
200 if(!
zip(
m_out,func,cxlevel,bufmax,src,bufmax,tgt,nout)) {
202 a_kbuf = (
char*)a_buffer.buf();
203 a_klen = a_buffer.length();
215 a_kbuf = (
char*)a_buffer.buf();
216 a_klen = a_buffer.length();
◆ compression()
virtual uint32 tools::wroot::file::compression |
( |
| ) |
const |
|
inlinevirtual |
◆ dir() [1/2]
Definition at line 397 of file file.
◆ dir() [2/2]
const directory& tools::wroot::file::dir |
( |
| ) |
const |
|
inline |
Definition at line 398 of file file.
◆ END()
virtual seek tools::wroot::file::END |
( |
| ) |
const |
|
inlinevirtual |
◆ error_number()
int tools::wroot::file::error_number |
( |
| ) |
|
|
inlineprotected |
Definition at line 761 of file file.
◆ is_open()
bool tools::wroot::file::is_open |
( |
| ) |
const |
|
inline |
Definition at line 367 of file file.
367 {
return (
m_file==not_open()?
false:
true);}
◆ make_free_seg()
bool tools::wroot::file::make_free_seg |
( |
seek |
a_first, |
|
|
seek |
a_last |
|
) |
| |
|
inlineprotected |
Definition at line 589 of file file.
600 m_out <<
"tools::wroot::file::make_free_seg :"
601 <<
" free_seg list should not be empty here."
608 m_out <<
"tools::wroot::file::make_free_seg :"
609 <<
" add_free failed."
614 seek nfirst = newfree->first();
615 seek nlast = newfree->last();
617 seek _nbytes = nlast-nfirst+1;
619 int nbytes = -int(_nbytes);
621 int nb =
sizeof(int);
624 const char* eob = psave + nb;
628 if(!wb.write(nbytes))
return false;
631 if(!
set_pos(nfirst))
return false;
◆ operator=()
file& tools::wroot::file::operator= |
( |
const file & |
| ) |
|
|
inlineprotected |
Definition at line 354 of file file.
◆ out()
virtual std::ostream& tools::wroot::file::out |
( |
| ) |
const |
|
inlinevirtual |
◆ path()
const std::string& tools::wroot::file::path |
( |
| ) |
const |
|
inline |
Definition at line 356 of file file.
◆ reset_error_number()
void tools::wroot::file::reset_error_number |
( |
| ) |
|
|
inlineprotected |
Definition at line 762 of file file.
◆ s_class()
static const std::string& tools::wroot::file::s_class |
( |
| ) |
|
|
inlinestatic |
Definition at line 39 of file file.
40 static const std::string s_v(
"tools::wroot::file");
◆ s_cls()
virtual const std::string& tools::wroot::file::s_cls |
( |
| ) |
const |
|
inlinevirtual |
Definition at line 43 of file file.
◆ set_compression()
void tools::wroot::file::set_compression |
( |
uint32 |
a_level | ) |
|
|
inline |
Definition at line 358 of file file.
◆ set_END()
virtual void tools::wroot::file::set_END |
( |
seek |
a_end | ) |
|
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 80 of file file.
84 m_out <<
"tools::wroot::file::set_END :"
85 <<
" free_seg list should not be empty here."
90 m_out <<
"tools::wroot::file::set_END :"
91 <<
" last free_seg is not the ending of file one."
92 <<
" free_seg list looks corrupted."
◆ set_pos()
virtual bool tools::wroot::file::set_pos |
( |
seek |
a_offset = 0 , |
|
|
from |
a_from = begin |
|
) |
| |
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 49 of file file.
63 #if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
64 if (::lseek64(
m_file, a_offset, whence) < 0) {
65 #elif defined(_MSC_VER)
66 if (::_lseeki64(
m_file, a_offset, whence) < 0) {
68 if (::lseek(
m_file, a_offset, whence) < 0) {
70 m_out <<
"tools::wroot::file::set_pos :"
71 <<
" cannot set position " << a_offset
72 <<
" in file " << sout(
m_path) <<
"."
◆ synchronize()
virtual bool tools::wroot::file::synchronize |
( |
| ) |
|
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 137 of file file.
141 m_out <<
"tools::wroot::file::synchronize :"
142 <<
" in _commit() for file " << sout(
m_path) <<
"."
146 #elif defined(__MINGW32__) || defined(__MINGW64__)
149 if (::fsync(
m_file) < 0) {
150 m_out <<
"tools::wroot::file::synchronize :"
151 <<
" error in fsync() for file " << sout(
m_path) <<
"."
◆ unlink()
static bool tools::wroot::file::unlink |
( |
const std::string & |
a_path | ) |
|
|
inlinestaticprotected |
Definition at line 473 of file file.
477 if (::stat(a_path.c_str(),&finfo) < 0)
return false;
479 if (finfo.st_mode & S_IFDIR)
480 return (::_rmdir(a_path.c_str())==-1 ?
false :
true);
482 return (::
unlink(a_path.c_str())==-1 ?
false :
true);
484 if (S_ISDIR(finfo.st_mode))
485 return (::rmdir(a_path.c_str())==-1 ?
false :
true);
487 return (::
unlink(a_path.c_str())==-1 ?
false :
true);
◆ verbose()
virtual bool tools::wroot::file::verbose |
( |
| ) |
const |
|
inlinevirtual |
◆ version()
virtual uint32 tools::wroot::file::version |
( |
| ) |
const |
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 126 of file file.
128 static const uint32 ROOT_MAJOR_VERSION = 4;
129 static const uint32 ROOT_MINOR_VERSION = 0;
130 static const uint32 ROOT_PATCH_VERSION = 0;
132 10000 * ROOT_MAJOR_VERSION +
133 100 * ROOT_MINOR_VERSION +
◆ write()
bool tools::wroot::file::write |
( |
uint32 & |
a_nbytes | ) |
|
|
inline |
Definition at line 400 of file file.
413 m_out <<
"tools::wroot::file::write :"
414 <<
" writing Name=" << sout(
m_path)
415 <<
" Title=" << sout(
m_title) <<
"."
423 m_out <<
"tools::wroot::file::write :"
424 <<
" write_streamer_infos failed."
430 m_out <<
"tools::wroot::file::write :"
431 <<
" can't write free segments."
437 m_out <<
"tools::wroot::file::write :"
438 <<
" can't write file header."
◆ write_buffer()
virtual bool tools::wroot::file::write_buffer |
( |
const char * |
a_buffer, |
|
|
uint32 |
a_length |
|
) |
| |
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 100 of file file.
106 while ((siz = ::
write(
m_file,a_buffer,a_length)) < 0 &&
110 m_out <<
"tools::wroot::file::write_buffer :"
111 <<
" error writing to file " << sout(
m_path) <<
"."
115 if(siz!=(ssize_t)a_length) {
116 m_out <<
"tools::wroot::file::write_buffer :"
117 <<
"error writing all requested bytes to file " << sout(
m_path)
118 <<
", wrote " << long_out(siz) <<
" of " << a_length
◆ write_free_segments()
bool tools::wroot::file::write_free_segments |
( |
| ) |
|
|
inlineprotected |
Definition at line 637 of file file.
643 m_out <<
"tools::wroot::file::write_free_segments :"
644 <<
" key.write_self() failed."
654 nbytes += (*it)->record_size();
658 if(!nbytes)
return true;
660 wroot::key key(
m_out,*
this,
664 if(!key.seek_key())
return false;
666 {
char* pos = key.data_buffer();
669 if(!(*it)->fill_buffer(wb))
return false;
673 if(!key.write_self(*
this)) {
674 m_out <<
"tools::wroot::file::write_free_segments :"
675 <<
" key.write_self() failed."
683 m_out <<
"tools::wroot::file::write_free_segments :"
684 <<
" write key." << std::endl;
688 if(!key.write_file(*
this,n))
return false;
◆ write_header()
bool tools::wroot::file::write_header |
( |
| ) |
|
|
inlineprotected |
Definition at line 498 of file file.
499 const char root[] =
"root";
502 const char* eob = psave + kBegin();
504 ::memcpy(pos,root,4); pos += 4;
513 if(!wb.write(vers))
return false;
516 if(!wb.write(
m_END))
return false;
525 if(!wb.write(nfree))
return false;
527 if(!wb.write(
m_units))
return false;
◆ write_streamer_infos()
bool tools::wroot::file::write_streamer_infos |
( |
| ) |
|
|
inlineprotected |
Definition at line 543 of file file.
544 obj_list<streamer_info> sinfos;
547 if(sinfos.empty())
return false;
551 if(!sinfos.stream(bref)) {
552 m_out <<
"tools::wroot::file::write_streamer_infos :"
553 <<
" cannot stream obj_list<streamer_info>."
557 uint32 nbytes = bref.length();
559 wroot::key key(
m_out,*
this,
564 if(!key.seek_key())
return false;
566 if(!bref.displace_mapped(key.key_length()))
return false;
568 ::memcpy(key.data_buffer(),bref.buf(),nbytes);
571 if(!key.write_self(*
this)) {
572 m_out <<
"tools::wroot::file::write_streamer_infos :"
573 <<
" key.write_self() failed."
583 if(!key.write_file(*
this,n))
return false;
◆ zip()
static bool tools::wroot::file::zip |
( |
std::ostream & |
a_out, |
|
|
compress_func |
a_func, |
|
|
int |
a_level, |
|
|
uint32 |
a_srcsize, |
|
|
char * |
a_src, |
|
|
uint32 |
a_tgtsize, |
|
|
char * |
a_tgt, |
|
|
uint32 & |
a_irep |
|
) |
| |
|
inlinestaticprotected |
Definition at line 694 of file file.
705 if(a_tgtsize<HDRSIZE) {
706 a_out <<
"tools::wroot::directory::zip :"
707 <<
" target buffer too small."
712 if(a_srcsize>0xffffff) {
713 a_out <<
"tools::wroot::directory::zip :"
714 <<
" source buffer too big."
721 if(!a_func(a_out,a_level,
723 a_tgtsize,a_tgt+HDRSIZE,
725 a_out <<
"tools::wroot::directory::zip :"
731 if((HDRSIZE+out_size)>a_tgtsize) {
732 a_out <<
"tools::wroot::directory::zip :"
733 <<
" target buffer overflow."
744 a_tgt[3] = (char)(out_size & 0xff);
745 a_tgt[4] = (char)((out_size >> 8) & 0xff);
746 a_tgt[5] = (char)((out_size >> 16) & 0xff);
748 a_tgt[6] = (char)(a_srcsize & 0xff);
749 a_tgt[7] = (char)((a_srcsize >> 8) & 0xff);
750 a_tgt[8] = (char)((a_srcsize >> 16) & 0xff);
752 a_irep = HDRSIZE+out_size;
◆ ziper()
virtual bool tools::wroot::file::ziper |
( |
char |
a_key, |
|
|
compress_func & |
a_func |
|
) |
| const |
|
inlinevirtual |
Implements tools::wroot::ifile.
Definition at line 159 of file file.
160 std::map<char,compress_func>::const_iterator it =
m_zipers.find(a_key);
165 a_func = (*it).second;
◆ m_BEGIN
seek tools::wroot::file::m_BEGIN |
|
protected |
Definition at line 778 of file file.
◆ m_compress
uint32 tools::wroot::file::m_compress |
|
protected |
Definition at line 785 of file file.
◆ m_END
seek tools::wroot::file::m_END |
|
protected |
Definition at line 779 of file file.
◆ m_file
int tools::wroot::file::m_file |
|
protected |
Definition at line 769 of file file.
◆ m_free_segs
std::list<free_seg*> tools::wroot::file::m_free_segs |
|
protected |
Definition at line 774 of file file.
◆ m_nbytes_free
uint32 tools::wroot::file::m_nbytes_free |
|
protected |
Definition at line 781 of file file.
◆ m_nbytes_info
uint32 tools::wroot::file::m_nbytes_info |
|
protected |
Definition at line 787 of file file.
◆ m_nbytes_name
uint32 tools::wroot::file::m_nbytes_name |
|
protected |
Definition at line 783 of file file.
◆ m_out
std::ostream& tools::wroot::file::m_out |
|
protected |
Definition at line 766 of file file.
◆ m_path
std::string tools::wroot::file::m_path |
|
protected |
Definition at line 767 of file file.
◆ m_root_directory
directory tools::wroot::file::m_root_directory |
|
protected |
Definition at line 772 of file file.
◆ m_seek_free
seek tools::wroot::file::m_seek_free |
|
protected |
Definition at line 780 of file file.
◆ m_seek_info
seek tools::wroot::file::m_seek_info |
|
protected |
Definition at line 786 of file file.
◆ m_title
std::string tools::wroot::file::m_title |
|
protected |
Definition at line 771 of file file.
◆ m_units
char tools::wroot::file::m_units |
|
protected |
Definition at line 784 of file file.
◆ m_verbose
bool tools::wroot::file::m_verbose |
|
protected |
Definition at line 768 of file file.
◆ m_version
uint32 tools::wroot::file::m_version |
|
protected |
Definition at line 777 of file file.
◆ m_zipers
Definition at line 773 of file file.
The documentation for this class was generated from the following file:
- /Users/barrand/private/dev/softinex/g4tools/g4tools/tools/wroot/file
#define tools_lforcit(a__T, a__l, a__it)