Toggle navigation
Beam GIT List
GitHub
Repo
Changelog
To do
Releases
Themes
Change log
Loading change log ...
To do ...
Loading todo ...
browsing:
e18d75e8aa9405e8af88e159bd26f678f3dbdc39
Branches
master
Tags
tms/release-pre-2.1.0
tms/release-2.2.1
tms/release-2.2.0
tms/release-2.1.0
tms/release-2.0.6
tms/release-2.0.5
tms/release-2.0.4
tms/release-2.0.3first
tms/release-2.0.3
tms/release-1.2.12
tms/release-1.2.11
tms/release-1.2.10
tms/release-1.2.9
tms/release-1.2.8
tms/release-1.2.6a
tms/release-1.2.6
tms/release-1.2.4
tms/release-1.2.3
tms/release-1.2.2
tms/release-1.2.0
tms/release-1.1.2
tms/release-1.1.1
tms/release-1.0.2
tms/release-1.0.1
tms/release-1.0.0
tms/release-0.4.3
tms/release-0.4.2
tms/release-0.4.1
tms/release-0.3.14
tms/release-0.3.13
tms/release-0.3.12
tms/release-0.3.10
tms/release-0.3.9
tms/release-0.3.8
tms/release-0.3.5
tms/release-0.3.4
tms/release-0.3.3
tms/release-0.2.7
tms/release-0.2.5
tms/release-0.2.3
tms-mcsys/release-2.1.0-1.beam
tms-mcsys/release-2.0.6-1.beam
tms-mcsys/release-1.2.9-1.beam
tms-fpga/release-1.2.5
tms-fpga/release-1.2.4
Files
Commits
Log
Graph
Stats
tms-old
beam
libBeam
BFile.cpp
RSS
Git
Fetch origin
Download
ZIP
TAR
Clone
Raw
View
History
Clone
HTTPS
Blames found: 30
Mode: text/x-c++src
Binary: false
Hang on, we reloading big blames...
6ae0d525
/******************************************************************************* * BFile.cc BEAM BFile access class * T.Barnaby, BEAM Ltd, 27/11/95 ******************************************************************************* */ #include <stdarg.h> #include <BFile.h> #include <sys/stat.h> #include <string.h> #include <errno.h>
57456599
#include <unistd.h>
6ae0d525
#define STRBUF 10240 BFile::BFile(){ ofile = NULL; } BFile::BFile(const BFile& file){
57456599
open(file.ofileName, file.omode);
6ae0d525
} BFile& BFile::operator=(const BFile& file){ open(file.ofileName, file.omode); return *this; } BFile::~BFile(){ close(); } BError BFile::open(BString name, BString mode){ BError err; ofileName = name; omode = mode;
57456599
if(! (ofile = fopen64(name, mode))) err.set(-errno, BString("Cannot open file: ") + name + ": " + strerror(errno));
6ae0d525
return err; } BError BFile::open(FILE* file){ BError err; ofile = file;
57456599
return err; } BError BFile::open(int fd, BString mode){ BError err; if(! (ofile = fdopen(fd, mode))) err.set(-errno, strerror(errno));
6ae0d525
return err; } BError BFile::close(){ BError err;
57456599
int e;
6ae0d525
if(ofile){
57456599
if(e = fclose(ofile)) err.set(-errno, strerror(errno));
6ae0d525
ofile = 0; } return err; }
57456599
int BFile::isOpen(){ return (ofile != 0);
6ae0d525
}
57456599
int BFile::isEnd(){ return feof(ofile);
6ae0d525
}
57456599
FILE* BFile::getFd(){ return ofile; } BUInt64 BFile::length(){ struct stat64 s;
6ae0d525
57456599
fstat64(fileno(ofile), &s);
6ae0d525
return s.st_size; } int BFile::read(void* buf, int nbytes){ return fread(buf, 1, nbytes, ofile); } int BFile::readString(BString& str){ char buf[STRBUF];
57456599
if(fgets(buf, STRBUF)){
6ae0d525
str = buf; return str.len(); } else { return 0; } }
57456599
char* BFile::fgets(char* buf, size_t size){ return ::fgets(buf, size, ofile); }
6ae0d525
int BFile::write(const void* buf, int nbytes){ return fwrite(buf, 1, nbytes, ofile); } int BFile::writeString(const BString& str){ return fputs(str.retStr(), ofile); }
57456599
int BFile::seek(BUInt64 pos){ return fseeko64(ofile, pos, 0);
6ae0d525
}
57456599
BUInt64 BFile::position(){ return ftello64(ofile); }
6ae0d525
int BFile::setVBuf(char* buf, int mode, size_t size){ return setvbuf(ofile, buf, mode, size); } int BFile::printf(const char* fmt, ...){ va_list ap; va_start(ap, fmt); return vfprintf(ofile, fmt, ap); }
57456599
BError BFile::truncate(){ BError err; if(ftruncate(fileno(ofile), 0) < 0) err.set(-errno, strerror(errno)); return err; } BError BFile::flush(){ BError err; if(::fflush(ofile) != 0) err.set(-errno, strerror(errno)); return err; } BString BFile::fileName(){ return ofileName; }