Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /tivo_utils.c [61fbce] .. [5f14c6] Maximize Restore

  Switch to side-by-side view

--- a/tivo_utils.c
+++ b/tivo_utils.c
@@ -140,4 +140,23 @@
 	seedRandomness(sizeof(r), &r, seed);
 	sqlite3_result_int64(context, r);
 }
+
+int
+is_tivo_file(const char *path)
+{
+	unsigned char buf[5];
+	unsigned char hdr[5] = { 'T','i','V','o','\0' };
+	int fd;
+
+	/* read file header */
+	fd = open(path, O_RDONLY);
+	if( !fd )
+		return 0;
+	if( read(fd, buf, 5) < 0 )
+		buf[0] = 'X';
+	close(fd);
+
+	return !memcmp(buf, hdr, 5);
+}
+
 #endif