summaryrefslogtreecommitdiff
path: root/tumbler
diff options
context:
space:
mode:
authorAli Abdallah <ali@xfce.org>2018-10-21 11:14:16 +0200
committerAli Abdallah <ali@xfce.org>2018-10-21 11:14:16 +0200
commitda29dad8676b38b3e29396db1442d0ede6f6385d (patch)
treea4d5ce9afbf87c3d615adb451de576d4c1d30b83 /tumbler
parent301348a12b7de99ebbb8b3c574830874843deda8 (diff)
downloadtumbler-da29dad8676b38b3e29396db1442d0ede6f6385d.tar.gz
Check for sparse video files only on plugin side.
Move the sparse video files check to ffmpeg and gstreamer plugins.
Diffstat (limited to 'tumbler')
-rw-r--r--tumbler/tumbler-util.c41
-rw-r--r--tumbler/tumbler-util.h10
2 files changed, 45 insertions, 6 deletions
diff --git a/tumbler/tumbler-util.c b/tumbler/tumbler-util.c
index 9d656d5..a414e26 100644
--- a/tumbler/tumbler-util.c
+++ b/tumbler/tumbler-util.c
@@ -9,11 +9,11 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
@@ -29,8 +29,12 @@
#include <glib.h>
#include <gio/gio.h>
+#include <sys/stat.h>
+
#include <tumbler/tumbler-util.h>
+/* Float block size used in the stat struct */
+#define TUMBLER_STAT_BLKSIZE 512.
gchar **
@@ -130,3 +134,34 @@ tumbler_util_get_settings (void)
return settings;
}
+
+
+gboolean tumbler_util_guess_is_sparse (TumblerFileInfo *info)
+{
+ gchar *filename;
+ struct stat sb;
+ gboolean ret_val = FALSE;
+
+ g_return_val_if_fail (TUMBLER_IS_FILE_INFO (info), FALSE);
+
+ filename = g_filename_from_uri (tumbler_file_info_get_uri (info), NULL, NULL);
+
+ if (G_LIKELY(filename))
+ {
+ stat (filename, &sb);
+
+ g_free (filename);
+
+ /* Test sparse files on regular ones */
+ if (S_ISREG (sb.st_mode))
+ {
+ if (((TUMBLER_STAT_BLKSIZE * sb.st_blocks) / sb.st_size) < 0.8)
+ {
+ ret_val = TRUE;
+ }
+ }
+ }
+
+ return ret_val;
+}
+
diff --git a/tumbler/tumbler-util.h b/tumbler/tumbler-util.h
index b68db0a..809332e 100644
--- a/tumbler/tumbler-util.h
+++ b/tumbler/tumbler-util.h
@@ -9,11 +9,11 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
+ * You should have received a copy of the GNU Library General
+ * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
@@ -23,12 +23,16 @@
#include <glib.h>
+#include <tumbler/tumbler-file-info.h>
+
G_BEGIN_DECLS
gchar **tumbler_util_get_supported_uri_schemes (void) G_GNUC_MALLOC;
GKeyFile *tumbler_util_get_settings (void) G_GNUC_MALLOC;
+gboolean tumbler_util_guess_is_sparse (TumblerFileInfo *info);
+
G_END_DECLS
#endif /* !__TUMBLER_UTIL_H__ */