Commit 9db6ecf2 authored by Pascal Noisette's avatar Pascal Noisette
Browse files

- support windows de la barre de progression, y'en a bien besoin ...

parent 2615647b
......@@ -133,9 +133,12 @@ bool Interface_console::draw_trace(const string & filename, const int format){
while(!parser.is_end_of_parsing()) {
loaded = parser.get_size_loaded();
sleep(1); // We wait 1 second
loaded = parser.get_size_loaded();
#ifdef WIN32
Sleep(1000);
#else
sleep(1); // We wait 1 second
#endif
cout << "Loading of the trace : " << loaded << "%" << endl;
if(_main_window != NULL) { // If we have a window we show a progress bar
......
......@@ -6,6 +6,7 @@ int TokenSource::_cursor = 0;
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
std::ifstream TokenSource::_file;
int TokenSource::_filesize = 1;
#else
off_t TokenSource::_filesize = 1;
#endif
......@@ -42,21 +43,34 @@ void TokenSource::open(const char *filename){
_is_eof = false;
/* Getting the file size */
#if defined (WIN32)|| !defined(_POSIX_MAPPED_FILES)
_file.open(filename, ios::in);
// throw Error::_OPEN;
_file.seekg (0, ios::end);
TokenSource::_filesize = _file.tellg();
_file.seekg (0, ios::beg);
// throw Error::_FSTAT;
#else
struct stat buf;
if(stat(filename, &buf) == -1) {
throw Error::_FSTAT;
}
_filesize = buf.st_size;
#endif
if(_filesize == 0) {
if(TokenSource::_filesize == 0) {
throw Error::_EMPTY_FILE;
}
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
_file.open(filename, ios::in);
fill_buffer();
fill_buffer();
#else
if ((_fd = ::open(filename, O_RDONLY)) == -1) {
throw Error::_OPEN;
......@@ -220,7 +234,7 @@ int TokenSource::get_size_loaded() {
if (_file.bad())
return 3;
return (_file.tellg()*100.)/_filesize;
return (_file.tellg()*100.)/TokenSource::_filesize;
#else
if(_filesize == 0) {
return 1;
......
......@@ -43,13 +43,16 @@ private:
bool _is_eof;
static off_t _filesize;
#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
int _buffer_size;
static std::ifstream _file;
static int _filesize;
#else
int _fd;
static off_t _filesize;
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment