Skip to content

Commit

Permalink
Use fstat/_fstati64 to obtain the file size.
Browse files Browse the repository at this point in the history
Provide better filter defaults for multi-file mode.


git-svn-id: https://dvbcut.svn.sourceforge.net/svnroot/dvbcut/trunk@48 36490176-9c1c-0410-b649-dbf2af5787bf
  • Loading branch information
too-tired committed Jul 3, 2007
1 parent 0185a31 commit b5695e5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2007-07-03 Michael Riepe <[email protected]>

* src/buffer.cpp:
Use fstat/_fstati64 to obtain the file size. This is
required to overcome the 2 GB limit on 32-bit systems
(Windows in particular).

* src/defines.h:
Better defaults for multi-file mode.

2007-07-02 Michael Riepe <[email protected]>

* src/buffer.cpp:
Expand Down
19 changes: 15 additions & 4 deletions src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,26 @@ inbuffer::open(std::string filename, std::string *errmsg) {
*errmsg = filename + ": open: " + strerror(errno);
return false;
}
off_t size = ::lseek(f.fd, 0, SEEK_END);
if (size == -1) {
#ifdef __WIN32__
struct _stati64 st;
if (::_fstati64(f.fd, &st) == -1) {
#else /* __WIN32__ */
struct stat st;
if (::fstat(f.fd, &st) == -1) {
#endif /* __WIN32__ */
if (errmsg)
*errmsg = filename + ": lseek: " + strerror(errno);
*errmsg = filename + ": fstat: " + strerror(errno);
::close(f.fd);
return false;
}
if (!S_ISREG(st.st_mode)) {
if (errmsg)
*errmsg = filename + ": not a regular file";
::close(f.fd);
return false;
}
f.off = filesize;
f.end = filesize += size;
f.end = filesize += st.st_size;
files.push_back(f);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ static inline int videostream(int s=0)
#define DVBCUT_QSETTINGS_PATH "/" DVBCUT_QSETTINGS_DOMAIN "/" DVBCUT_QSETTINGS_PRODUCT "/"

#define DVBCUT_DEFAULT_LOADFILTER \
"Recognized files (*.dvbcut *.mpg *.rec *.ts *.tts *.vdr);;" \
"Recognized files (*.dvbcut *.mpg *.rec* *.ts *.tts* *.vdr);;" \
"dvbcut project files (*.dvbcut);;" \
"MPEG files (*.mpg *.rec *.ts *.tts *.vdr);;" \
"MPEG files (*.mpg *.rec* *.ts *.tts* *.vdr);;" \
"All files (*)"
#define DVBCUT_DEFAULT_IDXFILTER \
"dvbcut index files (*.idx);;All files (*)"
Expand Down

0 comments on commit b5695e5

Please sign in to comment.