summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-04-15 22:33:43 +0200
committerCarl Hetherington <cth@carlh.net>2022-05-05 21:46:30 +0200
commit85207b59bd065b5fd8d1c7c0302e153dcd941554 (patch)
tree36c50830c7689b38ffc1bd512da1ae1a33caf925 /src
parent22781828732837911d0dc9b60acdac7e98e673c8 (diff)
Add ::tell().
Diffstat (limited to 'src')
-rw-r--r--src/file.cc21
-rw-r--r--src/file.h4
2 files changed, 25 insertions, 0 deletions
diff --git a/src/file.cc b/src/file.cc
index 74db8396..8ab50293 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -175,6 +175,27 @@ File::seek(int64_t offset, int whence)
}
+int64_t
+File::tell()
+{
+ DCP_ASSERT(_file);
+#ifdef LIBDCP_WINDOWS
+ return _ftelli64(_file);
+#else
+ return ftell(_file);
+#endif
+}
+
+
+
+int
+File::error ()
+{
+ DCP_ASSERT(_file);
+ return ferror(_file);
+}
+
+
/** Windows can't "by default" cope with paths longer than 260 characters, so if you pass such a path to
* any boost::filesystem method it will fail. There is a "fix" for this, which is to prepend
* the string \\?\ to the path. This will make it work, so long as:
diff --git a/src/file.h b/src/file.h
index ec13fc82..037251c1 100644
--- a/src/file.h
+++ b/src/file.h
@@ -73,6 +73,10 @@ public:
char *gets(char *s, int size);
/** fseek/fseeki64 wrapper */
int seek(int64_t offset, int whence);
+ /** ftell/ftelli64 wrapper */
+ int64_t tell();
+ /** ferror wrapper */
+ int error();
void checked_write(void const * ptr, size_t size);
void checked_read(void* ptr, size_t size);